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

查看:29
本文介绍了使用预签名 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 中的这个 Url 在其参数中没有这样的选项:http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putObject-property

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天全站免登陆