本文介绍了nodejs诺克斯放到s3结果为403的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在nodejs项目中使用knox上传到Amazon s3存储桶,但无法通过403错误.我已经确保正确设置了密钥,秘密和存储桶.我真的可以从经验丰富的人那里得到一些帮助.
I'm trying to upload to an Amazon s3 bucket using knox in a nodejs project but can't get past a 403 error. I've ensured that the key,secret, and bucket are properly set. I could really use some help here from those with more experience.
我的节点代码如下:
var upload_test = function(){
var client = knox.createClient(
{
key: config.aws.key
, secret: config.aws.secret
, bucket: config.aws.bucket
}
);
fs.readFile('test.pdf', function(err,buf){
var req = client.put('6530/test.pdf', {
'Content-length': buf.length,
'Content-Type': 'application/pdf'
});
req.on('response',function(res){
if(res.statusCode === 200){
console.log('Success!');
req.on('data',function(chunk) {
console.log(chunk);
});
}
else {
console.log("Error statusCode: " + res.statusCode);
console.log("URL: " + req.url);
req.on('data',function(chunk){
console.log(chunk);
});
}
});
});
}
推荐答案
面向未来的观看者:
我的类似问题通过将存储桶名称更改为所有小写字母解决了
My similar problem was solved by changing my bucket name to all lowercase letters
digitalKarma-> digitalkarma
digitalKarma --> digitalkarma
这篇关于nodejs诺克斯放到s3结果为403的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!