I need your help for my upcoming conference talk
Are you LOOKING for a job in IoT? or Are you already WORKING in IoT?
Click one of the links below to fill out a one question survey.
Thank you, Chris
Are you LOOKING for a job in IoT? or Are you already WORKING in IoT?
Click one of the links below to fill out a one question survey.
Thank you, Chris
Lambda Function to return a 1x1 Pixel. It took me a while to figure out how to return binary data from Lambda through the AWS API Gateway. Here’s my Lambda function for returning a GIF image pixel.
'use strict';
exports.handler = function(event, context) {
var imageHex = "\x42\x4d\x3c\x00\x00\x00\x00\x00\x00\x00\x36\x00\x00\x00\x28\x00"+
"\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x18\x00\x00\x00"+
"\x00\x00\x06\x00\x00\x00\x27\x00\x00\x00\x27\x00\x00\x00\x00\x00"+
"\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00";
context.done(null, { "body":imageHex });
};
Then in the Method Response for the API Gateway I added Content-Type to the Response Header.
Then in the Integration Response I map Content-Type to the constant string, ‘image/gif’ (single quotes). In the Integration Response -> Body Mapping Templates I added a template for image/gif.
#set($inputRoot = $input.path('$'))
$inputRoot.body
Now I can call the pixel from my webapges.
<img src="https://api-gateway-url/stage/pixel.gif" />