mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-11-02 03:54:59 +08:00
refactor (api): move rm/mv/touch/mkdir to http post
This commit is contained in:
@ -49,7 +49,7 @@ export function http_post(url, data, type = "json", params) {
|
||||
xhr.open("POST", url, true);
|
||||
xhr.withCredentials = true;
|
||||
xhr.setRequestHeader("X-Requested-With", "XmlHttpRequest");
|
||||
if (type === "json") {
|
||||
if (data && type === "json") {
|
||||
data = JSON.stringify(data);
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ class FileSystem {
|
||||
return this._replace(path, "loading")
|
||||
.then((res) => this.current_path === dirname(path) ?
|
||||
this._ls_from_cache(dirname(path)) : Promise.resolve(res))
|
||||
.then(() => http_get(url))
|
||||
.then(() => http_post(url))
|
||||
.then((res) => {
|
||||
return cache.remove(cache.FILE_CONTENT, [currentShare(), path])
|
||||
.then(cache.remove(cache.FILE_CONTENT, [currentShare(), path], false))
|
||||
@ -228,7 +228,7 @@ class FileSystem {
|
||||
|
||||
const action_execute = (part_of_a_batch_operation = false) => {
|
||||
if (part_of_a_batch_operation === true) {
|
||||
return http_get(url)
|
||||
return http_post(url)
|
||||
.then(() => {
|
||||
return this._replace(destination_path, null, "loading")
|
||||
.then(() => this._refresh(destination_path));
|
||||
@ -240,7 +240,7 @@ class FileSystem {
|
||||
});
|
||||
}
|
||||
|
||||
return http_get(url)
|
||||
return http_post(url)
|
||||
.then(() => {
|
||||
return this._replace(destination_path, null, "loading")
|
||||
.then(() => origin_path !== destination_path ?
|
||||
@ -325,7 +325,7 @@ class FileSystem {
|
||||
return http_post(url, file, "blob", params);
|
||||
} else {
|
||||
const url = appendShareToUrl("/api/files/touch?path=" + prepare(path));
|
||||
return http_get(url);
|
||||
return http_post(url);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -347,7 +347,7 @@ class FileSystem {
|
||||
return this._replace(origin_path, "loading")
|
||||
.then(this._add(destination_path, "loading"))
|
||||
.then(() => this._refresh(origin_path, destination_path))
|
||||
.then(() => http_get(url))
|
||||
.then(() => http_post(url))
|
||||
.then((res) => {
|
||||
return this._remove(origin_path, "loading")
|
||||
.then(() => this._replace(destination_path, null, "loading"))
|
||||
|
||||
@ -67,10 +67,10 @@ func Init(a App) {
|
||||
files.HandleFunc("/cat", NewMiddlewareChain(FileAccess, middlewares, a)).Methods("OPTIONS")
|
||||
files.HandleFunc("/cat", NewMiddlewareChain(FileSave, middlewares, a)).Methods("POST")
|
||||
files.HandleFunc("/ls", NewMiddlewareChain(FileLs, middlewares, a)).Methods("GET")
|
||||
files.HandleFunc("/mv", NewMiddlewareChain(FileMv, middlewares, a)).Methods("GET")
|
||||
files.HandleFunc("/rm", NewMiddlewareChain(FileRm, middlewares, a)).Methods("GET")
|
||||
files.HandleFunc("/mkdir", NewMiddlewareChain(FileMkdir, middlewares, a)).Methods("GET")
|
||||
files.HandleFunc("/touch", NewMiddlewareChain(FileTouch, middlewares, a)).Methods("GET")
|
||||
files.HandleFunc("/mv", NewMiddlewareChain(FileMv, middlewares, a)).Methods("POST")
|
||||
files.HandleFunc("/rm", NewMiddlewareChain(FileRm, middlewares, a)).Methods("POST")
|
||||
files.HandleFunc("/mkdir", NewMiddlewareChain(FileMkdir, middlewares, a)).Methods("POST")
|
||||
files.HandleFunc("/touch", NewMiddlewareChain(FileTouch, middlewares, a)).Methods("POST")
|
||||
middlewares = []Middleware{ApiHeaders, SessionStart, LoggedInOnly}
|
||||
files.HandleFunc("/search", NewMiddlewareChain(FileSearch, middlewares, a)).Methods("GET")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user