We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nodejs 12.x
Using this lamda function to convert from heic to jpg and store to my s3 bucket. works locally, but on Lambda getting "params.Body is required" error
"use strict"; const gm = require('gm').subClass({imageMagick: true}); const root = process.env['LAMBDA_TASK_ROOT']; const path = process.env['PATH']; const libPath = process.env['PATH']; var AWS = require('aws-sdk'); var s3 = new AWS.S3(); // change the Lambda Runtime to use pre-built binary process.env['PATH'] = `${root}/bin:${path}`; process.env['LD_LIBRARY_PATH'] = `${root}/lib:${libPath}`; // convert HEIC to JPEG module.exports.handler = async (event, context, callback) => { let from = event.source_img_path; let to = event.destination_img_path let thumbnail = event.thumbnail // main let image = gm(from) .noProfile() if (thumbnail) { image = image.resize("128^", "128^") .crop(128, 128) } image.toBuffer('jpg', function (err, buffer) { let params = {Bucket: process.env.BUCKET_NAME, Key: to, Body: buffer}; new Promise(resolve => { s3.upload(params, function (err, result) { if (err) { console.log(err) throw new Error('Could not upload photo'); } else { console.log(result) resolve(result); } }) }) }) };
Does anyone know how to resolve this? Or the issue is that you can't use 'toBuffer' on Lambda? Thanks in advance.
The text was updated successfully, but these errors were encountered:
Add an imagemagick layer in lambda?
Sorry, something went wrong.
No branches or pull requests
Nodejs 12.x
Using this lamda function to convert from heic to jpg and store to my s3 bucket.
works locally, but on Lambda getting "params.Body is required" error
Does anyone know how to resolve this? Or the issue is that you can't use 'toBuffer' on Lambda? Thanks in advance.
The text was updated successfully, but these errors were encountered: