how to upload image on amazon s3 using nodejs and make it public

Viewed 8675

I am using the following code to upload the image on amazon S3, but it is not public. What else parameter do I need to pass to make it public.

var AWS = require('aws-sdk');
AWS.config.region = 'us-west-2';

var s3bucket = new AWS.S3({params: {Bucket: 'myBucket'}});
s3bucket.createBucket(function() {
var params = {Key: 'myKey', Body: 'Hello!'};
s3bucket.upload(params, function(err, data) {
if (err) {
  console.log("Error uploading data: ", err);
} else {
  console.log("Successfully uploaded data to myBucket/myKey");
}
});
});
3 Answers
Related