@@ -80,15 +80,51 @@ class RestSASServerAdapter implements ContentAdapter {
8080 parentItem : ContentItem ,
8181 folderName : string ,
8282 ) : Promise < ContentItem | undefined > {
83- throw new Error ( "cnf Method not implemented." ) ;
83+ const response = await this . fileSystemApi . createFileOrDirectory ( {
84+ sessionId : this . sessionId ,
85+ fileOrDirectoryPath : parentItem . uri . replace (
86+ `/compute/sessions/${ this . sessionId } /files/` ,
87+ "" ,
88+ ) ,
89+ fileProperties : { name : folderName , isDirectory : true } ,
90+ } ) ;
91+
92+ return this . enrichWithDataProviderProperties (
93+ this . filePropertiesToContentItem ( response . data ) ,
94+ ) ;
8495 }
8596
8697 public async createNewItem (
8798 parentItem : ContentItem ,
8899 fileName : string ,
89100 buffer ?: ArrayBufferLike ,
90101 ) : Promise < ContentItem | undefined > {
91- throw new Error ( "cni Method not implemented." ) ;
102+ const response = await this . fileSystemApi . createFileOrDirectory ( {
103+ sessionId : this . sessionId ,
104+ fileOrDirectoryPath : parentItem . uri . replace (
105+ `/compute/sessions/${ this . sessionId } /files/` ,
106+ "" ,
107+ ) ,
108+ fileProperties : { name : fileName , isDirectory : false } ,
109+ } ) ;
110+
111+ if ( buffer ) {
112+ const etag = response . headers . etag ;
113+ const filePath = getLink ( response . data . links , "GET" , "self" ) . uri . replace (
114+ `/compute/sessions/${ this . sessionId } /files/` ,
115+ "" ,
116+ ) ;
117+ await this . fileSystemApi . updateFileContentOnSystem ( {
118+ sessionId : this . sessionId ,
119+ filePath,
120+ body : new File ( [ buffer ] , response . data . name ) ,
121+ ifMatch : etag ,
122+ } ) ;
123+ }
124+
125+ return this . enrichWithDataProviderProperties (
126+ this . filePropertiesToContentItem ( response . data ) ,
127+ ) ;
92128 }
93129
94130 public async deleteItem ( item : ContentItem ) : Promise < boolean > {
0 commit comments