X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/45d9b3d7298daf82bfb93c82e4f2f8c125c45e79..5cc899fc13465c57f16adf69a593a4354e6e0eb3:/src/services/collection-service/collection-service.ts diff --git a/src/services/collection-service/collection-service.ts b/src/services/collection-service/collection-service.ts index 6aa2123d..c0d61bd2 100644 --- a/src/services/collection-service/collection-service.ts +++ b/src/services/collection-service/collection-service.ts @@ -20,7 +20,7 @@ export class CollectionService extends CommonResourceService } 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 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 } } + 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: {