Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion source/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion source/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export interface CreateComponentOptions {
name?: string;
data?: Data;
onProgress?: (progress: number) => unknown;
xhr?: XMLHttpRequest;
signal?: AbortSignal;
onAborted?: () => unknown;
}
Expand Down
9 changes: 1 addition & 8 deletions source/uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class Uploader<TEntityTypeMap extends Record<string, any>> {
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;
Expand Down Expand Up @@ -126,7 +126,6 @@ export class Uploader<TEntityTypeMap extends Record<string, any>> {
const fileNameParts = splitFileExtension(normalizedFileName);

this.data = options.data || {};
this.xhr = options.xhr;
this.onProgress = options.onProgress;
this.onAborted = options.onAborted;
this.onError = options.onError;
Expand All @@ -148,12 +147,6 @@ export class Uploader<TEntityTypeMap extends Record<string, any>> {
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 = "";
Expand Down
24 changes: 0 additions & 24 deletions test/session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)], {
Expand Down