-
Notifications
You must be signed in to change notification settings - Fork 861
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
Limit an upload filesize with a Pre-signed URL #424
Comments
I don't believe your use-case is supported for pre-signed urls, but take a look at Authenticating Requests in Browser-Based Uploads Using POST . This should cover your case and there is built-in support for limiting the upload size (along with other options) using a POST policy. |
Is the top answer here correct/endorsed? Essentially, it suggests setting Content-Length to the "maximum" length.
|
For any other wanderers that end up on this thread - if you set the Content-Length attribute when sending the request from your client, there a few possibilities:
In any case, a malicious user can override your client and manually send a HTTP request with whatever headers they want, including a much larger Content-Length than you may be expecting. Signed URLs do not protect against this! The only way is to setup an POST policy. Official docs here: https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-HTTPPOSTConstructPolicy.html More details here: https://janac.medium.com/sending-files-directly-from-client-to-amazon-s3-signed-urls-4bf2cb81ddc3?postPublishedType=initial Alternatively, you can have a Lambda that automatically deletes files that are larger than expected. |
Thanks for sharing the link to your post but it seems it is not public. This one is free to read https://zaccharles.medium.com/s3-uploads-proxies-vs-presigned-urls-vs-presigned-posts-9661e2b37932 |
Hey here's that link without paywall: https://towardsaws.com/sending-files-directly-from-client-to-amazon-s3-signed-urls-4bf2cb81ddc3?sk=88c25bcd8689b40a4fd4045d4cf93eff |
I'm using S3 to store users' files on my website. In order to optimize server load, I've configured a direct file upload from browser for my users. The flow is the following:
I want to protect my S3 storage from obusing, so I need the way to limit the maximum file size. Unfortunately, I have not found a way to do this via .Net SDK.
I've read about restriction polices for HTTP POST (http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-post-example.html). Can it be applied on a Pre-signed Url flow.
Regards, Vadim.
The text was updated successfully, but these errors were encountered: