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.
My node code is as follows:
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);
});
}
});
});
}