Kit Kit - 3 years ago 110
Node.js Question

S3 Force File Download with NodeJS

I am trying to force files to download from Amazon S3 using the GET request parameter


I first created a signed URL which works fine when I want to view the file.

I then attempt to redirect there with the
header. Here is my code:

res.writeHead(302, {
'response-content-disposition': 'attachment',
'Location': '',

However, this just redirects to the file and does not download it.

Also when I try and visit with the file with the
as GET variable:

..I reveive the following response:

The request signature we calculated does not match the signature you provided. Check your key and signing method.

Answer Source

The correct way of using the response-content-disposition option is to include it as a GET variable but you're not calculating the signature correctly.

You can find more information on how you should calculate the signature in the Amazon REST Authentication guide

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download