File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ function arrayBufferToBase64(buffer: ArrayBuffer): string {
1818 return window . btoa ( binary ) ;
1919}
2020
21+ function base64DecodeAsBlob ( text : string , type = 'text/plain;charset=UTF-8' ) {
22+ return fetch ( `data:${ type } ;base64,` + text ) . then ( response => response . blob ( ) ) ;
23+ }
24+
2125async function toArray < T > (
2226 asyncIterator : AsyncIterableIterator < T >
2327) : Promise < T [ ] > {
@@ -255,6 +259,9 @@ export class FileSystemDrive implements Contents.IDrive {
255259 if ( format === 'json' ) {
256260 const data = JSON . stringify ( content , null , 2 ) ;
257261 await writable . write ( data ) ;
262+ } else if ( format === 'base64' ) {
263+ const contentBlob = await base64DecodeAsBlob ( content ) ;
264+ await writable . write ( contentBlob ) ;
258265 } else {
259266 await writable . write ( content ) ;
260267 }
You can’t perform that action at this time.
0 commit comments