开发者

Creating S3 signed URLs in node.js

开发者 https://www.devze.com 2023-03-14 15:24 出处:网络
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'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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消