Update filesystem

This commit is contained in:
2020-11-17 23:39:27 +01:00
parent 09fa952ce3
commit d8236ce0f9
14 changed files with 3233 additions and 1128 deletions

View File

@@ -0,0 +1,58 @@
<script context="module">
export const fs_create_directory = (bucket, path, dir_name) => {
if (!path.startsWith("/")) {
path = "/" + path
}
let form = new FormData()
form.append("type", "dir")
return fetch(
window.api_endpoint + "/filesystem/" + bucket + encodeURIComponent(path + "/" + dir_name),
{method: "POST", body: form},
).then(resp => {
if (resp.status >= 400) {
throw new Error(resp.text())
}
})
}
export const fs_get_node = (bucket, path) => {
if (!path.startsWith("/")) {
path = "/" + path
}
return fetch(
window.api_endpoint + "/filesystem/" + bucket + encodeURIComponent(path) + "?stat",
).then(resp => {
if (resp.status >= 400) {
throw new Error(resp.text())
}
return resp.json()
})
}
export const fs_get_file_url = (bucket, path) => {
if (!path.startsWith("/")) {
path = "/" + path
}
return window.api_endpoint + "/filesystem/" + bucket + encodeURIComponent(path)
}
export const fs_delete_node = (bucket, path) => {
if (!path.startsWith("/")) {
path = "/" + path
}
return fetch(
window.api_endpoint + "/filesystem/" + bucket + encodeURIComponent(path),
{method: "DELETE"},
).then(resp => {
if (resp.status >= 400) {
throw new Error(resp.text())
}
})
}
</script>