@@ -5,7 +5,7 @@ import { Signal, ISignal } from '@lumino/signaling';
55import { Contents , ServerConnection } from '@jupyterlab/services' ;
66import { PathExt } from '@jupyterlab/coreutils' ;
77import { IDriveInfo } from './token' ;
8- import { mountDrive } from './requests' ;
8+ import { saveFile , mountDrive } from './requests' ;
99
1010let data : Contents . IModel = {
1111 name : '' ,
@@ -433,19 +433,26 @@ export class Drive implements Contents.IDrive {
433433 localPath : string ,
434434 options : Partial < Contents . IModel > = { }
435435 ) : Promise < Contents . IModel > {
436- /*const settings = this.serverSettings;
437- const url = this._getUrl(localPath);
438- const init = {
439- method: 'PUT',
440- body: JSON.stringify(options)
441- };
442- const response = await ServerConnection.makeRequest(url, init, settings);
443- // will return 200 for an existing file and 201 for a new file
444- if (response.status !== 200 && response.status !== 201) {
445- const err = await ServerConnection.ResponseError.create(response);
446- throw err;
447- }
448- const data = await response.json();*/
436+ // extract current drive name
437+ const currentDrive = this . _drivesList . filter (
438+ x =>
439+ x . name ===
440+ ( localPath . indexOf ( '/' ) !== - 1
441+ ? localPath . substring ( 0 , localPath . indexOf ( '/' ) )
442+ : localPath )
443+ ) [ 0 ] ;
444+
445+ // eliminate drive name from path
446+ const relativePath =
447+ localPath . indexOf ( '/' ) !== - 1
448+ ? localPath . substring ( localPath . indexOf ( '/' ) + 1 )
449+ : '' ;
450+
451+ const resp = await saveFile ( currentDrive . name , {
452+ path : relativePath ,
453+ param : options
454+ } ) ;
455+ console . log ( 'contents resp: ' , resp ) ;
449456
450457 Contents . validateContentsModel ( data ) ;
451458 this . _fileChanged . emit ( {
0 commit comments