Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass Content-MD5 header to presigned upload URL #140

Open
safoine27 opened this issue Mar 16, 2023 · 1 comment
Open

Pass Content-MD5 header to presigned upload URL #140

safoine27 opened this issue Mar 16, 2023 · 1 comment

Comments

@safoine27
Copy link

safoine27 commented Mar 16, 2023

The application we are working with uploads objects to buckets with Object Lock enabled, where a retention period is set, using usePresignedUpload().

However, as per the AWS documentation, it is currently impossible to upload objects within buckets with Object Lock enabled and a retention period set, unless the Content-MD5 header is included in the request. As explained from the AWS docs

The Content-MD5 header is required for any request to upload an object with a retention period configured using Amazon S3 Object Lock

Currently, s3-upload is only able to pass custom headers to /api/s3-upload, and the only headers that we are passing to the PutObject request are Content-Type and Cache-Control.

To address this issue, we want to pass the MD5 digest to the request inside https://github.com/ryanto/next-s3-upload/blob/master/packages/next-s3-upload/src/hooks/use-presigned-upload.ts#L15-L16. The header should be optional and the digest value should be calculated from the application code.

I’d be happy to open a pull request to enable the passing of the Content-MD5 header (or any other extra headers) to the pre-signed upload request.

@williamrjribeiro
Copy link
Contributor

That's a very handy feature that I would love very much to see added to this library.

But... since the MD5 Digest is required by AWS for immutable buckets, maybe the library could calculate the digest for the application? 💭

I'm not sure if the philosophy of this library is "battery included", but if it is, then I believe it would be a perfect fit.
The exposed API could be something simple like a property:

const { uploadToS3 } = usePresignedUpload({ isImmutableBucket: true });

What y'all think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants