I am trying to get a .jpg file from a bucket and send it back to api gateway. I believe I have the setup correct as I see stuff being logged. It grabs the file from s3 fine, and gm is the graphicsmagick library. Not sure if I am using it right though.
In the lambda function I do this (alot of the code comes from the aws example):
async.waterfall([
function download(next) {
console.log(srcKey);
console.log(srcBucket);
// Download the image from S3 into a buffer.
s3.getObject({
Bucket: srcBucket,
Key: srcKey
},
next);
},
function transform(response, next) {
console.log(response);
next(null, 'image/jpeg', gm(response.Body).quality(85));
},
function sendData(contentType, data, next){
console.log(contentType);
console.log(data);
imageBuffer = data.sourceBuffer;
context.succeed(imageBuffer);
}
]
);
The response header has content-length: 85948, which doesn't seem right because the original file is only 36kb. Anyone know what I'm doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…