Skip to content

Commit

Permalink
Set tus properties more explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
Murderlon committed Jan 23, 2025
1 parent 5bec1c1 commit 9fa3f7d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
9 changes: 3 additions & 6 deletions packages/@uppy/aws-s3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
11 changes: 4 additions & 7 deletions packages/@uppy/xhr-upload/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,28 +440,25 @@ 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(
allowedMetaFields.map((name) => [name, file.meta[name]]),
),
httpMethod: opts.method,
useFormData: opts.formData,
headers: opts.headers,
}
}

Expand Down

0 comments on commit 9fa3f7d

Please sign in to comment.