问题描述
var newImage = await sharp(originalBuffer).resize(newWidth,newHeight,{
fit: sharp.fit.inside,withoutEnlargement: true
});
console.log(`after resize before to buffer ${typeof newImage} `,newImage)
// works on localhost mac but not on aws lambda
// https://github.com/lovell/sharp/issues/2085#issuecomment-587187740
newImage = await newImage.toBuffer();
错误是
Error: undefined Input buffer contains unsupported image format Error: Input buffer contains unsupported image format
使用express-fileupload
上传文件。认为这里不重要。也尝试过multer
我研究了很多,还没有找到解决方法
解决方法
我不确定,但是lambda函数是否与api网关链接,在将数据发送到函数时,在运行Sharp脚本之前,您需要通过控制台日志查看。它会成为您的数据吗?有时我们无法从函数中获取Api网关请求主体。尝试发送带有application / json标头或表单数据的邮件。