使用预签名URL上载到Amazon S3时限制对象的大小 [英] Limit Size Of Objects While Uploading To Amazon S3 Using Pre-Signed URL

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

问题描述

我知道使用此方法限制对象的上传大小: http://doc.s3.amazonaws.com/proposals/post.html#Limiting_Uploaded_Content

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

但是我想知道如何在服务器端使用IAM用户使用S3 SDK生成预签名的url时完成.

But i would like to know how it can be done while generating a pre-signed url using S3 SDK on the server side as an IAM user.

SDK的此网址在其参数中没有此类选项:

This Url from SDK has no such option in its parameters : http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putObject-property

都不是: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#getSignedUrl-property

请注意:我已经知道此答案: AWS S3预签名URL内容长度,它不是我想要的.

Please note: I already know of this answer: AWS S3 Pre-signed URL content-length and it is NOT what i am looking for.

推荐答案

V4签名协议提供了在签名中包含任意标头的选项.看: http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html 因此,如果您事先知道确切的Content-Length,则可以将其包括在签名的URL中.根据对CURL的一些实验,如果您发送的内容多于Content-Length标头中指定的内容,S3将截断该文件.这是示例V4签名,签名中包含多个标头 http://docs.aws.amazon .com/general/latest/gr/sigv4-add-signature-to-request.html

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

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

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