diff --git a/source/session.ts b/source/session.ts index 042951d7..beca42ca 100644 --- a/source/session.ts +++ b/source/session.ts @@ -977,7 +977,6 @@ export class Session< * @param {?object} [options = {}] - Options * @param {?string} options.name - Component name. Defaults get from file object. * @param {?number} options.data - Component data. Defaults to {}. - * @param {XMLHttpRequest} options.xhr - Custom XHR object, deprecated in favor of options.signal. * @param {AbortSignal} options.signal - Abort signal * @return {Promise} Promise resolved with the response when creating * Component and ComponentLocation. diff --git a/source/types.ts b/source/types.ts index 4f2dac06..2f90c7d5 100644 --- a/source/types.ts +++ b/source/types.ts @@ -20,7 +20,6 @@ export interface CreateComponentOptions { name?: string; data?: Data; onProgress?: (progress: number) => unknown; - xhr?: XMLHttpRequest; signal?: AbortSignal; onAborted?: () => unknown; } diff --git a/source/uploader.ts b/source/uploader.ts index 867ad21a..60ba6f4e 100644 --- a/source/uploader.ts +++ b/source/uploader.ts @@ -64,7 +64,7 @@ export class Uploader> { private onError: UploaderOptions["onError"]; /** Called on upload completion */ private onComplete: UploaderOptions["onComplete"]; - /** XHR for single-part upload. @deprecated */ + /** XHR for single-part upload. */ private xhr?: XMLHttpRequest; /** File type / extension */ private fileType: string; @@ -126,7 +126,6 @@ export class Uploader> { const fileNameParts = splitFileExtension(normalizedFileName); this.data = options.data || {}; - this.xhr = options.xhr; this.onProgress = options.onProgress; this.onAborted = options.onAborted; this.onError = options.onError; @@ -148,12 +147,6 @@ export class Uploader> { if (this.numParts <= 2) { this.numParts = null; } - if (this.xhr) { - logger.warn( - "[session.createComponent] options.xhr is deprecated and not compatible with multi-part uploads, use options.signal for aborting uploads.", - ); - this.numParts = null; - } this.activeConnections = {}; this.parts = []; this.uploadId = ""; diff --git a/test/session.test.ts b/test/session.test.ts index 9bd2bf9a..6739e24e 100755 --- a/test/session.test.ts +++ b/test/session.test.ts @@ -320,30 +320,6 @@ describe("Session", () => { expect(response[0].data.__entity_type__).toEqual("FileComponent"); }); - it("Should support abort of uploading file using xhr", async () => { - const data = { foo: "bar" }; - const blob = new Blob([JSON.stringify(data)], { - type: "application/json", - }); - - const xhr = new XMLHttpRequest(); - const promise = new Promise((resolve) => { - const onAborted = () => { - resolve(true); - }; - - session.createComponent(blob, { - xhr, - name: "data.json", - onProgress: () => { - xhr.abort(); - }, - onAborted, - }); - }); - await expect(promise).resolves.toEqual(true); - }); - it("Should support abort of uploading file using signal", async () => { const data = { foo: "bar" }; const blob = new Blob([JSON.stringify(data)], {