Unable To Download S3 Objects With Node
I am trying to download an S3 object while using node, and have asked this previous question. Code is below. I am declaring my access key credentials as environment variables and h
Solution 1:
This problem is that you are setting up "config" after creating the S3 Client. Change your code to look like this:
var AWS = require('aws-sdk');
AWS.config = new AWS.Config();
AWS.config.accessKeyId = "myAccessKey";
AWS.config.secretAccessKey = "mySecretAccessKey";
AWS.config.region = "us-east-1";
var s3 = new AWS.S3();
var params = { Bucket: "myBucket", Key: "fileName" }
s3.getObject(params, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
});
Post a Comment for "Unable To Download S3 Objects With Node"