diff --git a/src/api.ts b/src/api.ts index 0a421ce..0595371 100644 --- a/src/api.ts +++ b/src/api.ts @@ -335,6 +335,28 @@ export async function getFile(path: string): Promise { }); } + +/** + * fetchPost will secretly convert data into json, this func merely return Blob + * @param endpoint + * @returns + */ +export const getFileBlob = async (path: string): Promise => { + const endpoint = '/api/file/getFile' + let response = await fetch(endpoint, { + method: 'POST', + body: JSON.stringify({ + path: path + }) + }); + if (!response.ok) { + return null; + } + let data = await response.blob(); + return data; +} + + export async function putFile(path: string, isDir: boolean, file: any) { let form = new FormData(); form.append('path', path);