Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restrict the size of the file being uploaded on to the AWS S3 service using presigned urls

I'm using an AWS S3 presigned url to upload picture from a client (mobile app). I want to prevent the user to upload large files. Is there a way to limit the file size of an uploaded file?

Thanks

like image 801
user2522935 Avatar asked Jun 26 '13 07:06

user2522935


People also ask

How do I limit the size of a S3 bucket?

There are no configuration available that will limit the size of Amazon S3 buckets. You can, however, obtain Amazon S3 metrics in Amazon CloudWatch. You could create an alarm on a bucket to send a notification when the amount of data stored in an Amazon S3 bucket exceeds a certain threshold.

What is the size limit when using the single put upload method in S3?

Upload a single object using the Amazon S3 Console—With the Amazon S3 Console, you can upload a single object up to 160 GB in size.

What is the file size limit in S3?

Individual Amazon S3 objects can now range in size from 1 byte all the way to 5 terabytes (TB). Now customers can store extremely large files as single objects, which greatly simplifies their storage experience.


1 Answers

Check out "content-length-range" in s3 policy. http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-HTTPPOSTConstructPolicy.html

The conditions in a POST policy is an array of objects, each of which is used to validate the contents of the uploaded object. You can use these conditions to restrict what is allowed in the request. Each form field that you specify in a form (except x-amz-signature, file, policy, and field names that have an x-ignore- prefix) must appear in the list of conditions.

content-length-range
The minimum and maximum allowable size for the uploaded content. This condition supports content-length-range condition match type.

like image 111
Nat Avatar answered Sep 19 '22 17:09

Nat