如何使用预签名的URL限制上传到AWS S3服务的文件的大小 [英] How to restrict the size of the file being uploaded on to the AWS S3 service using presigned urls

查看:513
本文介绍了如何使用预签名的URL限制上传到AWS S3服务的文件的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AWS S3预签名url从客户端(移动应用程序)上传图片. 我想防止用户上传大文件. 有没有办法限制上传文件的文件大小?

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?

谢谢

推荐答案

在s3策略中检出"content-length-range". http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-HTTPPOSTConstructPolicy.html

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

POST策略中的条件是一个对象数组,每个对象用于验证上载对象的内容.您可以使用这些条件来限制请求中所允许的内容.您在表单中指定的每个表单字段(x-amz签名,文件,策略和具有x-ignore-前缀的字段名称除外)都必须出现在条件列表中.

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
上载内容的最小和最大允许大小. 此条件支持content-length-range条件匹配类型.

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

这篇关于如何使用预签名的URL限制上传到AWS S3服务的文件的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆