Creating a signed S3 URL with Javascript

Question:

I am attempting to create a signed S3 URL using Javascript & NodeJS. I have used this
specification.

This creates a url similar to this:

However, I receive the following error when accessing it:

What am I doing wrong when creating the signature?

EDIT – ATTEMPT WITH KNOX

I am now attempting to use Knox to produce a signed URL. I need to add headers with the request to force download. I have edited the following:

Added amazonHeaders: 'response-content-disposition:attachment', to client.signedUrl- http://jsfiddle.net/BpGNM/1/

Added options.amazonHeaders + '\n' + to auth.queryStringToSignhttp://jsfiddle.net/6b8Tm/

The message that is now being sent to auth.hmacSha1 to create the the sig is:

I have then tried to access my new URL with the response-content-disposition=attachment added as GET var. However, I am still receiving the same error stated above.

Answer:

I would try using Knox along with Node.Js . Its known to be a great combination and also itself utilizes the Node.JS Crypto library which is kind of what you’re trying to do – saving you time:)

More info here : https://github.com/LearnBoost/knox

Than, you could just do something like:

Edit:
You could also look into Knox and just check what the signedUrl function does and implement that yourself.Than you could add to the auth.signQuery call an extra option called amazonHeaders:

Shai.

Leave a Reply