X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/31e84a9315728c2f58a26bf0e9e1d2b38326fb86..62cb779efb0b098c05053e957c765a807467b28b:/src/common/webdav.ts diff --git a/src/common/webdav.ts b/src/common/webdav.ts index 758a5e18..d4f904ae 100644 --- a/src/common/webdav.ts +++ b/src/common/webdav.ts @@ -30,6 +30,12 @@ export class WebDAV { data }) + get = (url: string, config: WebDAVRequestConfig = {}) => + this.request({ + ...config, url, + method: 'GET' + }) + upload = (url: string, files: File[], config: WebDAVRequestConfig = {}) => { return Promise.all( files.map(file => this.request({ @@ -84,6 +90,15 @@ export class WebDAV { .keys(headers) .forEach(key => r.setRequestHeader(key, headers[key])); + if (!(window as any).cancelTokens) { + Object.assign(window, { cancelTokens: {} }); + } + + (window as any).cancelTokens[config.url] = () => { + resolve(r); + r.abort(); + } + if (config.onUploadProgress) { r.upload.addEventListener('progress', config.onUploadProgress); } @@ -129,4 +144,4 @@ interface RequestConfig { headers?: { [key: string]: string }; data?: any; onUploadProgress?: (event: ProgressEvent) => void; -} \ No newline at end of file +}