tus / tus-js-client

A pure JavaScript client for the tus resumable upload protocol
https://tus.io/
MIT License
2.12k stars 316 forks source link

Add metadata into parallel uploads. #701

Closed loren-m-crawford closed 2 months ago

loren-m-crawford commented 4 months ago

👋 This PR is more of a proposal to allow for parallel uploads to keep the metadata from the original request. My team has found that maintaining metadata in the parallel upload requests would benefit our use case.

The PR does two main things:

  1. Adds an option retainMetadataForParallelUploads that is defaulted to false. This option would be for our use case (or anyone else's) that would allow the retention of metadata in partial uploads, too.
  2. Checks the retainMetadataForParallelUploads option during the parallel upload logic. If it's set to true, then we ensure the metadata is maintained, if it is false (default behavior), we remove it.
Acconut commented 4 months ago

Thanks for opening this PR! You're right that tus-js-client currently does not offer a way to set metadata for partial uploads. This is not ideal, especially since we also mention that metadata can be used to identify the users corresponding to an upload. I wonder if there are also use case where one wants to use different meta data for partial uploads versus the final upload. In such cases, an option to retain the meta data would not be sufficient and we would need an option to specify custom metadata for the partial uploads.

What do you think?

loren-m-crawford commented 4 months ago

@Acconut 👋 You make a good point. Perhaps instead of maintaining the metadata from the original request, there can be an additional option for parallel upload metadata that can either be the same as the original request metadata or be more tailored. Thinking maybe something like: https://github.com/loren-m-crawford/tus-js-client/pull/2/files What do you think?

Acconut commented 2 months ago

Superseeded by https://github.com/tus/tus-js-client/pull/703.