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 {
18
18
return window . btoa ( binary ) ;
19
19
}
20
20
21
+ function base64DecodeAsBlob ( text : string , type = 'text/plain;charset=UTF-8' ) {
22
+ return fetch ( `data:${ type } ;base64,` + text ) . then ( response => response . blob ( ) ) ;
23
+ }
24
+
21
25
async function toArray < T > (
22
26
asyncIterator : AsyncIterableIterator < T >
23
27
) : Promise < T [ ] > {
@@ -255,6 +259,9 @@ export class FileSystemDrive implements Contents.IDrive {
255
259
if ( format === 'json' ) {
256
260
const data = JSON . stringify ( content , null , 2 ) ;
257
261
await writable . write ( data ) ;
262
+ } else if ( format === 'base64' ) {
263
+ const contentBlob = await base64DecodeAsBlob ( content ) ;
264
+ await writable . write ( contentBlob ) ;
258
265
} else {
259
266
await writable . write ( content ) ;
260
267
}
You can’t perform that action at this time.
0 commit comments