On S3 document, there is createPresignedPost and getSignedUrl.
On getSignedUrl:
Note: Not all operation parameters are supported when using pre-signed URLs. Certain parameters, such as SSECustomerKey, ACL, Expires, ContentLength, or Tagging must be provided as headers when sending a request. If you are using pre-signed URLs to upload from a browser and need to use these fields, see createPresignedPost().
Is createPresignedPost simply more customizable version of getSignedUrl? Is it doing the same thing underneath?
A presigned URL gives you access to the object identified in the URL, provided that the creator of the presigned URL has permissions to access that object.
Pre-signed URLs are used to provide short-term access to a private object in your S3 bucket. They work by appending an AWS Access Key, expiration time, and Sigv4 signature as query parameters to the S3 object. There are two common use cases when you may want to use them: Simple, occasional sharing of private files.
POST is an alternate form of PUT that enables browser-based uploads as a way of putting objects in buckets. Parameters that are passed to PUT through HTTP Headers are instead passed as form fields to POST in the multipart/form-data encoded message body.
Anyone can use a valid presigned URL Just to make sure this is clear: if you generate a presigned URL anyone can use this, the user generating this link could use it to phish another user and let them upload an arbitrary file. So be sure you threat model properly your feature to avoid logic vulnerabilities.
If you want to restrict users from uploading files beyond certain size, you should be using createPresigendPost
, and specify ContentLength
with getSignedUrl, there is no restricting object size and user can potentially upload a 5TB object (current object limit) to s3
Note that if you can specify ContentLength in params when calling getSignedUrl('putObject',params, callback) you will be thrown
Presigning post data encountered an error { UnexpectedParameter: ContentLength is not supported in pre-signed URLs.
There is an issue on this subject
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With