Add file upload and download (zip for directories)

This commit is contained in:
sarah committed 2026-09-28 22:57:09 +02:00
1 parent 0d564982dc
commit da4e02472f
7 files changed
+383 -42

No files matched your search

+19
View File
@@ -156,6 +156,25 @@ export function GetRawFileUrl(RootName, RelativePath) {
return `${ApiBase}/raw/${encodeURIComponent(RootName)}/${EncodedSegments.join("/")}`;
}
export function GetDownloadUrl(RootName, RelativePath) {
const Params = new URLSearchParams({ Root: RootName, Path: RelativePath });
return `${ApiBase}/download?${Params}`;
}
export async function UploadFiles(RootName, RelativePath, Files) {
const Form = new FormData();
for (const File of Files) {
Form.append("Files", File);
}
const Params = new URLSearchParams({ Root: RootName, Path: RelativePath });
const Response = await fetch(`${ApiBase}/upload?${Params}`, {
method: "POST",
credentials: "same-origin",
body: Form,
});
return ParseJsonOrThrow(Response);
}
export function SaveFile(RootName, RelativePath, Content) {
const Params = new URLSearchParams({ Root: RootName, Path: RelativePath });
return FetchJson(`/file?${Params}`, { method: "PUT", body: Content });