Add sharing settings to filesystem

This commit is contained in:
2023-05-11 19:07:29 +02:00
parent f0847da15f
commit 80a1085f78
6 changed files with 160 additions and 20 deletions

View File

@@ -6,6 +6,11 @@ export const fs_get_file_url = (bucket, path) => {
return path_url(bucket, path)
}
export const fs_split_path = (path) => {
let patharr = path.split("/")
return { base: patharr.pop(), parent: patharr.join("/") }
}
export const fs_mkdir = async (bucket, path, opts = null) => {
const form = new FormData()
form.append("action", "mkdir")
@@ -23,7 +28,7 @@ export const fs_mkdir = async (bucket, path, opts = null) => {
export const fs_get_node = async (bucket, path) => {
const resp = await fetch(path_url(bucket, path) + "?stat");
if (resp.status >= 400) {
throw new Error(await resp.text())
throw await resp.text()
}
return resp.json()
}
@@ -39,18 +44,24 @@ export const fs_update = async (bucket, path, opts) => {
const form = new FormData()
form.append("action", "update")
if (opts.created) {
if (opts.created !== undefined) {
form.append("created", opts.created.toISOString())
}
if (opts.modified) {
if (opts.modified !== undefined) {
form.append("modified", opts.modified.toISOString())
}
if (opts.mode) {
if (opts.mode !== undefined) {
form.append("mode", opts.mode)
}
if (opts.shared) {
if (opts.shared !== undefined) {
form.append("shared", opts.shared)
}
if (opts.read_password !== undefined) {
form.append("read_password", opts.read_password)
}
if (opts.write_password !== undefined) {
form.append("write_password", opts.write_password)
}
const resp = await fetch(path_url(bucket, path), { method: "POST", body: form })
if (resp.status >= 400) {