- async deleteFile(collectionUuid: string, filePath: string) {
- return this.webdavClient.delete(`/c=${collectionUuid}${filePath}`);
- }
-
- extractFilesData(document: Document) {
- return Array
- .from(document.getElementsByTagName('D:response'))
- .slice(1)
- .map(element => {
- const name = getTagValue(element, 'D:displayname', '');
- const size = parseInt(getTagValue(element, 'D:getcontentlength', '0') as string, 10);
- const pathname = getTagValue(element, 'D:href', '');
- const directory = pathname && pathname.replace(/\/c=[0-9a-zA-Z\-]*/, '').replace(`/${name || ''}`, '');
- const href = this.webdavClient.defaults.baseURL + pathname + '?api_token=' + this.authService.getApiToken();
-
- const data = {
- url: href,
- id: `${directory}/${name}`,
- name,
- path: directory,
- };
-
- const [resourceTypeElement] = Array.from(element.getElementsByTagName('D:resourcetype'));
- return resourceTypeElement && resourceTypeElement.innerHTML === ''
- ? createCollectionFile({ ...data, size })
- : createCollectionDirectory(data);
-
- });
+ async deleteFiles(collectionUuid: string, filePaths: string[]) {
+ for (const path of filePaths) {
+ const splittedPath = path.split('/');
+ if (collectionUuid) {
+ await this.webdavClient.delete(`c=${collectionUuid}/${splittedPath[1]}`);
+ } else {
+ await this.webdavClient.delete(`c=${collectionUuid}${path}`);
+ }
+ }