Remove the need to provide a bucket ID to each API call
This commit is contained in:
@@ -14,7 +14,7 @@ export const fs_check_response = async resp => {
|
||||
return JSON.parse(text)
|
||||
}
|
||||
|
||||
export const fs_mkdir = async (bucket, path, opts = null) => {
|
||||
export const fs_mkdir = async (path, opts = null) => {
|
||||
const form = new FormData()
|
||||
form.append("action", "mkdir")
|
||||
|
||||
@@ -23,11 +23,11 @@ export const fs_mkdir = async (bucket, path, opts = null) => {
|
||||
}
|
||||
|
||||
return await fs_check_response(
|
||||
await fetch(fs_path_url(bucket, path), { method: "POST", body: form })
|
||||
await fetch(fs_path_url(path), { method: "POST", body: form })
|
||||
)
|
||||
}
|
||||
|
||||
export const fs_mkdirall = async (bucket, path, opts = null) => {
|
||||
export const fs_mkdirall = async (path, opts = null) => {
|
||||
const form = new FormData()
|
||||
form.append("action", "mkdirall")
|
||||
|
||||
@@ -36,13 +36,13 @@ export const fs_mkdirall = async (bucket, path, opts = null) => {
|
||||
}
|
||||
|
||||
return await fs_check_response(
|
||||
await fetch(fs_path_url(bucket, path), { method: "POST", body: form })
|
||||
await fetch(fs_path_url(path), { method: "POST", body: form })
|
||||
)
|
||||
}
|
||||
|
||||
export const fs_get_node = async (bucket, path) => {
|
||||
export const fs_get_node = async path => {
|
||||
return await fs_check_response(
|
||||
await fetch(fs_path_url(bucket, path) + "?stat")
|
||||
await fetch(fs_path_url(path) + "?stat")
|
||||
)
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ export const fs_get_node = async (bucket, path) => {
|
||||
// - shared, boolean. If true the node will receive a public ID
|
||||
//
|
||||
// Returns the modified filesystem node object
|
||||
export const fs_update = async (bucket, path, opts) => {
|
||||
export const fs_update = async (path, opts) => {
|
||||
const form = new FormData()
|
||||
form.append("action", "update")
|
||||
|
||||
@@ -77,45 +77,45 @@ export const fs_update = async (bucket, path, opts) => {
|
||||
}
|
||||
|
||||
return await fs_check_response(
|
||||
await fetch(fs_path_url(bucket, path), { method: "POST", body: form })
|
||||
await fetch(fs_path_url(path), { method: "POST", body: form })
|
||||
)
|
||||
}
|
||||
|
||||
export const fs_rename = async (bucket, old_path, new_path) => {
|
||||
export const fs_rename = async (old_path, new_path) => {
|
||||
const form = new FormData()
|
||||
form.append("action", "rename")
|
||||
form.append("target", new_path)
|
||||
|
||||
return await fs_check_response(
|
||||
await fetch(fs_path_url(bucket, old_path), { method: "POST", body: form })
|
||||
await fetch(fs_path_url(old_path), { method: "POST", body: form })
|
||||
)
|
||||
}
|
||||
|
||||
export const fs_delete = async (bucket, path) => {
|
||||
export const fs_delete = async path => {
|
||||
return await fs_check_response(
|
||||
await fetch(fs_path_url(bucket, path), { method: "DELETE" })
|
||||
await fetch(fs_path_url(path), { method: "DELETE" })
|
||||
)
|
||||
}
|
||||
export const fs_delete_all = async (bucket, path) => {
|
||||
export const fs_delete_all = async path => {
|
||||
return await fs_check_response(
|
||||
await fetch(fs_path_url(bucket, path) + "?recursive", { method: "DELETE" })
|
||||
await fetch(fs_path_url(path) + "?recursive", { method: "DELETE" })
|
||||
)
|
||||
}
|
||||
|
||||
export const fs_search = async (bucket, path, term, limit = 10) => {
|
||||
export const fs_search = async (path, term, limit = 10) => {
|
||||
return await fs_check_response(
|
||||
await fetch(
|
||||
fs_path_url(bucket, path) +
|
||||
fs_path_url(path) +
|
||||
"?search=" + encodeURIComponent(term) +
|
||||
"&limit=" + limit
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
export const fs_timeseries = async (bucket, path, start, end, interval = 60) => {
|
||||
export const fs_timeseries = async (path, start, end, interval = 60) => {
|
||||
return await fs_check_response(
|
||||
await fetch(
|
||||
fs_path_url(bucket, path) +
|
||||
fs_path_url(path) +
|
||||
"?timeseries" +
|
||||
"&start=" + start.toISOString() +
|
||||
"&end=" + end.toISOString() +
|
||||
|
Reference in New Issue
Block a user