From 9fa3f7d54b11d9ae2d7ae0dad4a7080bdd3affbc Mon Sep 17 00:00:00 2001 From: Murderlon Date: Thu, 23 Jan 2025 14:08:21 +0100 Subject: [PATCH] Set tus properties more explicitly --- packages/@uppy/aws-s3/src/index.ts | 9 +++------ packages/@uppy/xhr-upload/src/index.ts | 11 ++++------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/packages/@uppy/aws-s3/src/index.ts b/packages/@uppy/aws-s3/src/index.ts index 3f7f0fcbe9..5912398175 100644 --- a/packages/@uppy/aws-s3/src/index.ts +++ b/packages/@uppy/aws-s3/src/index.ts @@ -929,17 +929,14 @@ export default class AwsS3Multipart< // Since the Transloadit plugin uses the tus plugin underneath, it's possible to have file.tus // even though we are in this plugin. // @ts-expect-error typed in @uppy/tus - if (file.tus) { - // @ts-expect-error typed in @uppy/tus - Object.assign(opts, file.tus) - } + const tusOpts = file.tus return { ...file.remote?.body, - endpoint: opts.endpoint, + endpoint: tusOpts.endpoint ?? opts.endpoint, protocol: this.uppy.getState().remoteUploader || 's3-multipart', size: file.data.size, - headers: opts.headers, + headers: { ...opts.headers, ...tusOpts.headers }, metadata: file.meta, } } diff --git a/packages/@uppy/xhr-upload/src/index.ts b/packages/@uppy/xhr-upload/src/index.ts index 99aacb9526..29cfca8006 100644 --- a/packages/@uppy/xhr-upload/src/index.ts +++ b/packages/@uppy/xhr-upload/src/index.ts @@ -440,20 +440,18 @@ export default class XHRUpload< opts.allowedMetaFields, file.meta, ) - // When you .use(AwsS3) with .use(Transloadit, { companionOnly: true }), + // When you .use(XHR) with .use(Transloadit, { companionOnly: true }), // local files are uploaded with this plugin and remote files with the Transloadit plugin. // Since the Transloadit plugin uses the tus plugin underneath, it's possible to have file.tus // even though we are in this plugin. // @ts-expect-error typed in @uppy/tus - if (file.tus) { - // @ts-expect-error typed in @uppy/tus - Object.assign(opts, file.tus) - } + const tusOpts = file.tus return { ...file.remote?.body, protocol: this.uppy.getState().remoteUploader || 'multipart', - endpoint: opts.endpoint, + endpoint: tusOpts.endpoint ?? opts.endpoint, + headers: { ...opts.headers, ...tusOpts.headers }, size: file.data.size, fieldname: opts.fieldName, metadata: Object.fromEntries( @@ -461,7 +459,6 @@ export default class XHRUpload< ), httpMethod: opts.method, useFormData: opts.formData, - headers: opts.headers, } }