The goal is to have have AWS lambda copy a specific jpg from a URL each day to an S3 bucket. This seems like a super simple lambda function but its just not working. I have this setup as a local NPM project then upload the zipped files in the AWS lambda console. The code below runs without error but does not copy the image. Any help would be greatly appreciated.
"use strict";
const AWS = require("aws-sdk");
const Jimp = require("jimp");
const s3 = new AWS.S3();
const imageType = "image/jpeg";
const bucket = 'mybucket';
exports.handler = (event, context, callback) => {
let objectKey = 'myimage.jpg';
Jimp.read('sampleURL.com/image.jpg')
.then(image => {
s3.putObject({
Bucket: bucket,
Key: objectKey,
Body: image,
ContentType: imageType
})
})
.catch(err => {
// Handle an exception.
});
};
aws cloudwatch logs
2019-10-24T12:48:23.105Z bac7d80e-5544-4ea5-ae12-478281338389 INFO { Error: Could not find MIME for Buffer <null>
at Jimp.parseBitmap (/var/task/node_modules/@jimp/core/dist/utils/image-bitmap.js:120:15)
at Jimp.parseBitmap (/var/task/node_modules/@jimp/core/dist/index.js:506:32)
at /var/task/node_modules/@jimp/core/dist/index.js:448:15
at /var/task/node_modules/@jimp/core/dist/index.js:176:14
at /var/task/node_modules/@jimp/core/dist/request.js:66:9
at IncomingMessage.<anonymous> (/var/task/node_modules/phin/lib/phin.compiled.js:1:2100)
at IncomingMessage.emit (events.js:203:15)
at IncomingMessage.EventEmitter.emit (domain.js:448:20)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19) methodName: 'constructor' }
END RequestId: bac7d80e-5544-4ea5-ae12-478281338389
REPORT RequestId: bac7d80e-5544-4ea5-ae12-478281338389 Duration: 612.63 ms Billed Duration: 700 ms Memory Size: 128 MB Max Memory Used: 97 MB Init Duration: 557.69 ms