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

Ability to upload using createdPresignedPost #179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scastiel
Copy link

@scastiel scastiel commented Feb 5, 2024

My ultimate need is to be able to set a maximum upload file size. After looking for the best way to do it, it looks like it is possible using createPresignedPost. It works similarly to getPresignedUrl, but it lets us pass a Conditions parameter that can include the content-length-range.

This PR is currently more a proof of concept of using createPresignedPost to upload the file to S3, with a maximum file size. I think this feature doesn’t add too much complexity to the project and could benefit other users.

Let me know if you think it’s a good idea, I can work more to make it ready for production (additional testing, documentation update, etc.).

Copy link

vercel bot commented Feb 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-s3-upload ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 5, 2024 9:45pm

@@ -60,6 +60,7 @@
"@aws-sdk/client-s3": ">=3.427.0",
"@aws-sdk/client-sts": "^3.427.0",
"@aws-sdk/lib-storage": ">=3.427.0",
"@aws-sdk/s3-presigned-post": "3.427.0",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to require the exact version, otherwise two versions of S3Client live in the project.

Key: key,
Expires: 60 * 60,
Conditions: [
["content-length-range", 0, 512 * 1024],
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part controls the maximum uploaded file size. Obviously, this should be configurable, i.e. it should be possible to send Conditions when using useS3Upload for instance.

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

Successfully merging this pull request may close these issues.

1 participant