What's working so far:
Using this function, I'm taking images that are uploaded to my server, sending them to an aws S3 bucket and then deleting them from my machine. That's all working great.
The problem:
How do I configure the image so that amazon serves it as public and with the proper Content-Type(image/jpeg or image/png)? Right now it defaults to private and (application/octet-stream).
Is this something that I can configure in node? or do I need to do that 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);
}
});
});
}