X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/5a7d3c08744413b659fd24be59992fc1daa486e5..0534b585de71147120e880fe670ebd0e61dcf68f:/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 +}