init
This commit is contained in:
20
src/services/file.ts
Normal file
20
src/services/file.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import API from "../middleware/Api";
|
||||
|
||||
export async function getDownloadURL(file: any): Promise<any> {
|
||||
let reqURL = "";
|
||||
if (file.key) {
|
||||
const downloadPath =
|
||||
file.path === "/"
|
||||
? file.path + file.name
|
||||
: file.path + "/" + file.name;
|
||||
reqURL =
|
||||
"/share/download/" +
|
||||
file.key +
|
||||
"?path=" +
|
||||
encodeURIComponent(downloadPath);
|
||||
} else {
|
||||
reqURL = "/file/download/" + file.id;
|
||||
}
|
||||
|
||||
return API.put(reqURL);
|
||||
}
|
30
src/services/navigate.ts
Normal file
30
src/services/navigate.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import API from "../middleware/Api";
|
||||
|
||||
export async function list(
|
||||
path: string,
|
||||
share: any,
|
||||
keywords: string,
|
||||
searchPath: string
|
||||
): Promise<any> {
|
||||
let apiURL = "";
|
||||
if (share) {
|
||||
if (keywords === "") {
|
||||
apiURL = "/share/list/" + share.key;
|
||||
} else {
|
||||
apiURL = `/share/search/${share.key}/`;
|
||||
}
|
||||
} else {
|
||||
if (keywords === "") {
|
||||
apiURL = "/directory";
|
||||
} else {
|
||||
apiURL = "/file/search/";
|
||||
}
|
||||
}
|
||||
|
||||
path = keywords === "" ? path : keywords;
|
||||
apiURL = apiURL + encodeURIComponent(path);
|
||||
if (searchPath) {
|
||||
apiURL = `${apiURL}?path=${encodeURIComponent(searchPath)}`;
|
||||
}
|
||||
return API.get(apiURL);
|
||||
}
|
Reference in New Issue
Block a user