WHITECOLOR WHITECOLOR - 5 months ago 40
Node.js Question

AWS S3 node.js SDK uploaded file and folder permissions

I'm uploading file to S3 using aws-sdk package:

fs.readFile(sourceFile, function (err, data) {
if (err) { throw err; }

s3.client.putObject({
Bucket: bucketName,
Key: 'Folder/image.jpg',
Body: data
}, function (res) {
console.log('Successfully uploaded file.');
})

});


I I need to make uploaded file to be downloadable via cloudfront, if I asume right, I need to set permissions on file: Everyone Open/Download, Folder2 should be made public (via menu Make Public). So 2 questions:

1) How to set\modify permissions on uploaded file\folder?

2) How make Folder public using AWS SDK for node.js.

Answer

Found it http://docs.aws.amazon.com/AmazonS3/latest/dev/ACLOverview.html#CannedACL

need to add option in putObject:

ACL:'public-read'
Comments