var express = require('express');
var knox = require('knox');
var app = express();
app.use(express.bodyParser());
var s3 = knox.createClient({
key: process.env.AWS_ACCESS_KEY_ID,
secret: process.env.AWS_SECRET_ACCESS_KEY,
bucket: process.env.S3_BUCKET_NAME
});
app.post('/upload', function(req, res, next) {
var photo = req.files.photo;
var s3Headers = {
'Content-Type': photo.type,
'x-amz-acl': 'public-read'
};
s3.putFile(photo.path, photo.name, s3Headers, function(err, s3response){
//handle, respond
});
});