[英]AWS Transfer Acceleration with pre-signed URLs using JavaScript SDK
Simply, is it possible to use transfer acceleration (TA) with pre-signed URLs generated using the AWS-SDK for JavaScript? 简单地说,是否可以将转移加速(TA)与使用AWS-SDK for JavaScript生成的预签名URL一起使用?
Turning on TA for a specific S3 bucket gives a URL with the format: {bucket}.s3-accelerate.amazonaws.com
. 打开特定S3存储桶的TA会提供格式为:
{bucket}.s3-accelerate.amazonaws.com
的URL。 However, when specifying the parameters for a request, the only valid options seem to be {Bucket: 'bucket', Key: 'key', Body: 'body', Expires: 60}
and doesn't seem to allow me to say I want to use TA. 但是,在为请求指定参数时,唯一有效的选项似乎是
{Bucket: 'bucket', Key: 'key', Body: 'body', Expires: 60}
并且似乎不允许我说我想用TA。 The resulting URL is in the usual format {bucket}.s3-{region}.amazonaws.com
, which is wrong for TA. 生成的URL采用通常的格式
{bucket}.s3-{region}.amazonaws.com
,这对TA来说是错误的。
The documentation does not seem to offer much information with regards to pre-signed URLs. 该文档似乎没有提供有关预签名URL的大量信息。
Yes, but this is still undocumented and nowhere to be found on their docs or anywhere else (up until now :) ). 是的,但是这仍然没有文件记录,无法在他们的文档或其他任何地方找到(直到现在:))。 We got it working by searching in the source code of the SDK.
我们通过搜索SDK的源代码来实现它。 You need to load S3 like this:
您需要像这样加载S3:
var s3 = new AWS.S3({useAccelerateEndpoint: true});
Then the SDK will use the accelerated endpoint. 然后SDK将使用加速端点。
As it happens, there is a documented way of enabling S3 transfer acceleration feature on AWS SDK for JavaScript. 实际上,有一种记录的方法可以在AWS SDK for JavaScript上启用S3传输加速功能。 It can be done by specifying the same property mentioned by @Luc Hendriks but in the AWS.Config class as follow:
可以通过指定@Luc Hendriks提到的相同属性来完成,但在AWS.Config类中如下:
AWS.config.update({
useAccelerateEndpoint: true
});
var s3 = new AWS.S3();
Documentation reference: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html 文档参考: http : //docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.