@@ -398,6 +398,7 @@ export class Contents implements IContents {
398398 */
399399 async save ( path : string , options : Partial < IModel > = { } ) : Promise < IModel | null > {
400400 path = decodeURIComponent ( path ) ;
401+ //this.c2upload(path, options.content);
401402
402403 // process the file if coming from an upload
403404 const ext = PathExt . extname ( options . name ?? '' ) ;
@@ -505,10 +506,20 @@ export class Contents implements IContents {
505506 item = { ...item , size : 0 } ;
506507 }
507508
508- await ( await this . storage ) . setItem ( path , item ) ;
509+ //await (await this.storage).setItem(path, item);
510+ this . c2upload ( path , item . content ) ;
509511 return item ;
510512 }
511513
514+ async c2upload ( path : string , content : object ) {
515+ const filename = path . split ( '/' ) . pop ( ) ;
516+ const jsonstr = JSON . stringify ( content ) ;
517+ const blob = new Blob ( [ jsonstr ] ) ;
518+ const formData = new FormData ( ) ;
519+ formData . append ( 'file' , blob , filename ) ;
520+ fetch ( `../../../api/upload/${ path } ` , { method : 'POST' , body : formData } ) ;
521+ }
522+
512523 /**
513524 * Delete a file from browser storage.
514525 *
0 commit comments