uppy icon indicating copy to clipboard operation
uppy copied to clipboard

[AWS S3 Uploader] Allow retrieving Object Version ID

Open ninanator opened this issue 9 months ago • 3 comments

Initial checklist

  • [X] I understand this is a feature request and questions should be posted in the Community Forum
  • [X] I searched issues and couldn’t find anything (or linked relevant results below)

Problem

AWS allows retrieving the version from versioning-enabled buckets with the x-amz-version-id response header (Read more).

For multi-part uploads, I am able to retrieve the version ID because I control the response with completeMultipartUpload. However, I am unable to retrieve this information while following the recommendation that files under 100 MiB are uploaded in a single chunk.

I would like to be able to access the version ID at the time the upload finishes for all upload types.

Solution

I think the easiest path would be to add versionId as an optional field on UploadPartBytesResult and populate in https://github.com/transloadit/uppy/blob/77c6b2512c5eae4bd95a6855d639cc428caba85f/packages/%40uppy/aws-s3-multipart/src/index.ts#L753

Alternatives

Always upload files in multiple parts, regardless of size

ninanator avatar May 02 '24 22:05 ninanator

@aduh95 maybe it would be nice to let users control what is returned in both multipart and non-multipart, instead of hardcoding it?

Murderlon avatar May 03 '24 08:05 Murderlon

I suppose we could use xhr.getAllResponseHeaders() and pass the result directly to the user, which can then cherry-pick what they need from it. Do you think that would fulfil your usecase @ninanator? I suppose it would only returns the headers that are allowed by CORS, but that's something the user controls.

aduh95 avatar May 03 '24 13:05 aduh95

@aduh95 @Murderlon

Returning all of the headers would be amazing!

To be honest, having a companion method like completeMultipartUpload for uploads initiated via getUploadParameters which has access to xhr.getAllResponseHeaders() would be the absolute best because I could then normalize what comes back to the body field of Success Response on the listener uppy.on('upload-success', ...) across all upload types.

ninanator avatar May 03 '24 14:05 ninanator