node.jsamazon-s3knox-amazon-s3-client

Creating S3 signed URLs in node.js


I'm using knox module to https://github.com/LearnBoost/knox to create signed URLs for files on S3, something I've done with PHP SDK before.

I can delete files from my bucket, but I'm getting SignatureDoesNotMatch error when I try the generated URLs for files with private ACL.

Code looks like this

var knox = require('knox');
var s3Client = knox.createClient({
key: '*****',
secret: '*****',
bucket: '*****'
});
function getS3Url(filename) {
var expires = new Date();
expires.setMinutes(expires.getMinutes() + 30);
return s3Client.signedUrl(filename, expires);
}
console.log(getS3Url('file.txt'));

What am I doing wrong?


Solution

  • Turns out I was missing the leading '/' on filename, signature matches now.