node.js - 在 node.js 中创建 S3 签名 URL

标签 node.js amazon-s3 knox-amazon-s3-client

我正在使用 knox 模块来 https://github.com/LearnBoost/knox为 S3 上的文件创建签名 URL,这是我之前使用 PHP SDK 完成的。

我可以从我的存储桶中删除文件,但是当我尝试为具有私有(private) ACL 的文件生成 URL 时,我收到 SignatureDoesNotMatch 错误。

代码是这样的

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'));

我做错了什么?

最佳答案

原来我在文件名中缺少前导“/”,现在签名匹配。

关于node.js - 在 node.js 中创建 S3 签名 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6447202/

相关文章:

node.js - S3、签名 URL 和缓存

javascript - Sequelize : Modify output of date timestamp using Getters

node.js - 如何将搜索与 Node Express 音频流结合起来

javascript - Passport ensureAuthenticated

python - Django S3 Direct 上的 CORS 错误

iphone - 如何将文件从 S3 下载到 iPhone 应用程序?

node.js - Mongoose 的 Populate 方法出现 MissingSchemaError

amazon-web-services - 使用无服务器创建 S3 存储桶时出现错误 `Bucket name should not contain uppercase characters`

node.js - nodejs knox 放入 s3 结果为 403

node.js 和 S3/使用 knox 写入 s3