Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

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.

like image 836
Chris Paton Avatar asked May 25 '16 12:05

Chris Paton


1 Answers

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.

like image 52
Luc Hendriks Avatar answered Oct 06 '22 21:10

Luc Hendriks