13860-process-statuses-filters
[arvados-workbench2.git] / src / services / collection-service / collection-service.ts
index 6aa2123d0c6ac228d7e2517116807ad247791a1e..c0d61bd27b4d5d789a09a0096c16154ddcbbb461 100644 (file)
@@ -20,7 +20,7 @@ export class CollectionService extends CommonResourceService<CollectionResource>
     }
 
     async files(uuid: string) {
-        const request = await this.webdavClient.propfind(`/c=${uuid}`);
+        const request = await this.webdavClient.propfind(`c=${uuid}`);
         if (request.responseXML != null) {
             const filesTree = parseFilesResponse(request.responseXML);
             return mapTreeValues(this.extendFileURL)(filesTree);
@@ -30,7 +30,7 @@ export class CollectionService extends CommonResourceService<CollectionResource>
 
     async deleteFiles(collectionUuid: string, filePaths: string[]) {
         for (const path of filePaths) {
-            await this.webdavClient.delete(`/c=${collectionUuid}${path}`);
+            await this.webdavClient.delete(`c=${collectionUuid}${path}`);
         }
     }
 
@@ -41,13 +41,20 @@ export class CollectionService extends CommonResourceService<CollectionResource>
         }
     }
 
+    moveFile(collectionUuid: string, oldPath: string, newPath: string) {
+        return this.webdavClient.move(
+            `c=${collectionUuid}${oldPath}`,
+            `c=${collectionUuid}${encodeURI(newPath)}`
+        );
+    }
+
     private extendFileURL = (file: CollectionDirectory | CollectionFile) => ({
         ...file,
         url: this.webdavClient.defaults.baseURL + file.url + '?api_token=' + this.authService.getApiToken()
     })
 
     private async uploadFile(collectionUuid: string, file: File, fileId: number, onProgress: UploadProgress = () => { return; }) {
-        const fileURL = `/c=${collectionUuid}/${file.name}`;
+        const fileURL = `c=${collectionUuid}/${file.name}`;
         const fileContent = await fileToArrayBuffer(file);
         const requestConfig = {
             headers: {