I'm trying to retrieve an image from s3 in node using the following:
app.get('/photos', function(req, res, next) {
var data = '';
s3.get('/tmp/DSC_0904.jpg').on('response', function(s3res){
console.log(s3res.statusCode);
console.log(s3res.headers);
s3res.setEncoding('binary');
s3res.on('data', function(chunk){
data += chunk;
});
s3res.on('end', function() {
res.contentType('image/jpeg');
res.send(data);
});
}).end();
});
I'm open to suggestions as to why this doesn't work.