Reputation: 3
What I need is getting an image via https://xxx.yyy/zzz/1040 rest api, and I will show the image to a SNS tool(Line) via imagemap API.
I am trying to get image saved in S3 bucket via lambda. Here is the flow I am trying to implement:
Issue:
I could not get the real image via both browser and postman
please help! and let me know if you need more detail information...
Lambda:
'use strict';
const aws = require('aws-sdk');
const s3 = new aws.S3({ region: 'ap-northeast-1' });
const BUCKET = 'test';
module.exports.handler = (event, context, callback) => {
console.log('====== started ====');
s3.getObject({ Bucket: BUCKET, Key: 'line-service-menu-option2.jpg' }).promise()
.then(data => {
callback(null, {
statusCode: 200,
headers: { 'Content-Type': 'image/jpeg'},
body: data.Body.toString('base64'),
isBase64Encoded: true,
});
}).catch(e => console.log(e));
};
lambda test log
{ "statusCode": 200, "headers": { "Content-Type": "image/jpeg" }, "body": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wC***********************",
"isBase64Encoded": true }
api gateway configuration
[API setting][1] [method request][2] [integration request][3] [integration response][4] [method response][5]
[1]: https://i.sstatic.net/Mvt13.jpg [2]: https://i.sstatic.net/E2tns.jpg [3]: https://i.sstatic.net/poNHl.jpg [4]: https://i.sstatic.net/JgVf8.jpg [5]: https://i.sstatic.net/IS00q.jpg
Upvotes: 0
Views: 1122