filestash/public/assets/pages/viewerpage/model_files.js
2024-06-24 23:19:40 +10:00

18 lines
563 B
JavaScript

import rxjs from "../../lib/rx.js";
import ajax from "../../lib/ajax.js";
import { getDownloadUrl, getCurrentPath } from "./common.js";
export const options = () => ajax({
url: `api/files/cat?path=${encodeURIComponent(getCurrentPath())}`,
method: "OPTIONS",
}).pipe(rxjs.map((res) => res.responseHeaders.allow.replace(/\r/, "").split(", ")));
export const cat = () => ajax(getDownloadUrl()).pipe(
rxjs.map(({ response }) => response),
);
export const save = (content) => ajax({
url: getDownloadUrl(),
method: "POST",
body: content,
});