小编cmk*_*cmk的帖子

从AWS Lambda函数中的S3获取对象并发送到Api Gateway

我试图从桶中获取.jpg文件并将其发送回api网关.我相信我的设置正确,因为我看到记录的东西.它从s3中获取文件,gm是graphicsmagick库.不知道我是否正在使用它.

在lambda函数中我这样做(很多代码来自aws示例):

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);
    }
    ]
);
Run Code Online (Sandbox Code Playgroud)

响应头的内容长度为:85948,这似乎不对,因为原始文件只有36kb.谁知道我做错了什么?

amazon-s3 amazon-web-services node.js aws-lambda aws-api-gateway

5
推荐指数
2
解决办法
9244
查看次数