Limit Size Of Objects While Uploading To Amazon S3 Using Pre-Signed URL

前端 未结 2 596
野趣味
野趣味 2020-12-14 15:57

I know of limiting the upload size of an object using this method: http://doc.s3.amazonaws.com/proposals/post.html#Limiting_Uploaded_Content

But i would like to know

相关标签:
2条回答
  • 2020-12-14 16:24

    The V4 signing protocol offers the option to include arbitrary headers in the signature. See: http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html So, if you know the exact Content-Length in advance, you can include that in the signed URL. Based on some experiments with CURL, S3 will truncate the file if you send more than specified in the Content-Length header. Here is an example V4 signature with multiple headers in the signature http://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html

    0 讨论(0)
  • 2020-12-14 16:24

    You may not be able to limit content upload size ex-ante, especially considering POST and Multi-Part uploads. You could use AWS Lambda to create an ex-post solution. You can setup a Lambda function to receive notifications from the S3 bucket, have the function check the object size and have the function delete the object or do some other action.

    Here's some documentation on Handling Amazon S3 Events Using the AWS Lambda.

    0 讨论(0)
提交回复
热议问题