File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import {
1010 IRegisteredFileTypes
1111} from './token' ;
1212import {
13+ addPublicDrive ,
1314 saveObject ,
1415 getContents ,
1516 mountDrive ,
@@ -662,6 +663,26 @@ export class Drive implements Contents.IDrive {
662663 return data ;
663664 }
664665
666+ /**
667+ * Add public drive.
668+ *
669+ * @param options: The options used to add the public drive.
670+ *
671+ * @returns A promise which resolves with the contents model.
672+ */
673+ async addPublicDrive ( driveUrl : string ) : Promise < Contents . IModel > {
674+ data = await addPublicDrive ( driveUrl ) ;
675+
676+ Contents . validateContentsModel ( data ) ;
677+ this . _fileChanged . emit ( {
678+ type : 'new' ,
679+ oldValue : null ,
680+ newValue : data
681+ } ) ;
682+
683+ return data ;
684+ }
685+
665686 /**
666687 * Create a checkpoint for a file.
667688 *
Original file line number Diff line number Diff line change @@ -533,6 +533,33 @@ export async function createDrive(
533533 return data ;
534534}
535535
536+ /**
537+ * Add public drive.
538+ *
539+ * @param driveUrl The public drive URL.
540+ *
541+ * @returns A promise which resolves with the contents model.
542+ */
543+ export async function addPublicDrive ( driveUrl : string ) {
544+ await requestAPI < any > ( 'drives/' + driveUrl + '/' , 'POST' , {
545+ public : true
546+ } ) ;
547+
548+ data = {
549+ name : driveUrl ,
550+ path : driveUrl ,
551+ last_modified : '' ,
552+ created : '' ,
553+ content : [ ] ,
554+ format : 'json' ,
555+ mimetype : '' ,
556+ size : 0 ,
557+ writable : true ,
558+ type : 'directory'
559+ } ;
560+ return data ;
561+ }
562+
536563namespace Private {
537564 /**
538565 * Helping function for renaming files inside
You can’t perform that action at this time.
0 commit comments