What works so far:
Using this function, I take images that are uploaded to my server, sending them to the aws S3 bucket and then deleting them from my machine. This all works great.
Problem:
How to configure an image so that amazon serves it as public and with the appropriate type of content (image / jpeg or image / png)? Currently, the default is private and (application / octet-stream).
Is this something I can configure in node? or do i need to do this in my aws console?
function sendFileToAmazon(file) { var s3bucket = new AWS.S3({ params: {Bucket: 'BUCKET NAME'} }); var params = {Key: file.name, Body: ''}; fs.readFile(file.path, function(err, data) { if (err) throw err; params.Body = data; s3bucket.putObject(params, function(errBucket, dataBucket) { if (errBucket) { console.log("Error uploading data: ", errBucket); } else { console.log(dataBucket); deleteFileFromTmp(file); } }); }); }
source share