8
votes

Simply, is it possible to use transfer acceleration (TA) with pre-signed URLs generated using the AWS-SDK for JavaScript?

Turning on TA for a specific S3 bucket gives a URL with the format: {bucket}.s3-accelerate.amazonaws.com. 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. The resulting URL is in the usual format {bucket}.s3-{region}.amazonaws.com, which is wrong for TA.

The documentation does not seem to offer much information with regards to pre-signed URLs.

2

2 Answers

24
votes

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. You need to load S3 like this:

var s3 = new AWS.S3({useAccelerateEndpoint: true});

Then the SDK will use the accelerated endpoint.

2
votes

As it happens, there is a documented way of enabling S3 transfer acceleration feature on AWS SDK for JavaScript. It can be done by specifying the same property mentioned by @Luc Hendriks but in the AWS.Config class as follow:

AWS.config.update({
    useAccelerateEndpoint: true
});

var s3 = new AWS.S3();

Documentation reference: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html