File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -335,6 +335,28 @@ export async function getFile(path: string): Promise<any> {
335335 } ) ;
336336}
337337
338+
339+ /**
340+ * fetchPost will secretly convert data into json, this func merely return Blob
341+ * @param endpoint
342+ * @returns
343+ */
344+ export const getFileBlob = async ( path : string ) : Promise < Blob | null > => {
345+ const endpoint = '/api/file/getFile'
346+ let response = await fetch ( endpoint , {
347+ method : 'POST' ,
348+ body : JSON . stringify ( {
349+ path : path
350+ } )
351+ } ) ;
352+ if ( ! response . ok ) {
353+ return null ;
354+ }
355+ let data = await response . blob ( ) ;
356+ return data ;
357+ }
358+
359+
338360export async function putFile ( path : string , isDir : boolean , file : any ) {
339361 let form = new FormData ( ) ;
340362 form . append ( 'path' , path ) ;
You can’t perform that action at this time.
0 commit comments