forked from hibas123/SecureFileWrapper
Adding new /files endpoint support
This commit is contained in:
parent
dddb5cb07b
commit
31080c2d96
16
src/index.ts
16
src/index.ts
@ -161,7 +161,7 @@ export default class SecureFileWrapper {
|
||||
async list(folder?: string): Promise<IFile[]> {
|
||||
let query: any = {}
|
||||
if (folder) query.folder = folder;
|
||||
let res = await this.makeRequest("/file", "GET", query);
|
||||
let res = await this.makeRequest("/files", "GET", query);
|
||||
let d = await res.json();
|
||||
return d.files;
|
||||
}
|
||||
@ -175,16 +175,16 @@ export default class SecureFileWrapper {
|
||||
params.folder = folder;
|
||||
}
|
||||
|
||||
let res = await this.makeRequest("/file", "POST", params, data);
|
||||
let res = await this.makeRequest("/files", "POST", params, data);
|
||||
return (await res.json()).file;
|
||||
}
|
||||
|
||||
async get(id: string, version?: string): Promise<ArrayBuffer> {
|
||||
let res: Response;
|
||||
if (typeof version === "string") {
|
||||
res = await this.makeRequest(`/file/${id}/history/${version}`, "GET", {});
|
||||
res = await this.makeRequest(`/files/${id}/history/${version}`, "GET", {});
|
||||
} else {
|
||||
res = await this.makeRequest("/file/" + id, "GET", {});
|
||||
res = await this.makeRequest("/files/" + id, "GET", {});
|
||||
}
|
||||
|
||||
if (res.arrayBuffer) {
|
||||
@ -199,25 +199,25 @@ export default class SecureFileWrapper {
|
||||
async update(id: string, data: ArrayBuffer | ArrayBufferView, preview?: string): Promise<IFile> {
|
||||
let put: any = {};
|
||||
if (preview) put.preview = preview;
|
||||
let res = await this.makeRequest("/file/" + id, "PUT", put, data);
|
||||
let res = await this.makeRequest("/files/" + id, "PUT", put, data);
|
||||
|
||||
let json = await res.json()
|
||||
return json.file;
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<boolean> {
|
||||
let res = await this.makeRequest("/file/" + id, "DELETE", {});
|
||||
let res = await this.makeRequest("/files/" + id, "DELETE", {});
|
||||
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async history(id: string): Promise<IHistory> {
|
||||
let res = await this.makeRequest(`/file/${id}/history`, "GET", {});
|
||||
let res = await this.makeRequest(`/files/${id}/history`, "GET", {});
|
||||
statusParser(res);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async restore(id: string, version: string) {
|
||||
await this.makeRequest(`/file/${id}/history/${version}/restore`, "PUT", {});
|
||||
await this.makeRequest(`/files/${id}/history/${version}/restore`, "PUT", {});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user