【问题标题】:node js resize png doesnt work on aws lambda onlynode js resize png 仅在 aws lambda 上不起作用
【发布时间】:2020-09-26 04:51:55
【问题描述】:
        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

我研究了很多,还没有找到解决办法

【问题讨论】:

    标签: node.js sharp


    【解决方案1】:

    我不确定,但如果 lambda 函数与 api 网关链接,则在运行前你需要在发送数据以运行时查看控制台日志。它是 undefiend 还是与您的数据相同?有时我们无法从函数中获取 Api 网关请求正文。尝试使用 application/json 标头或表单数据发送。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-24
      • 2019-09-09
      • 1970-01-01
      • 1970-01-01
      • 2019-10-10
      • 1970-01-01
      • 1970-01-01
      • 2023-01-15
      相关资源
      最近更新 更多