I cannot get python lambda to return binary data. The node-template for thumbnail images works fine but I cannot get a python lambda to work. Below is the relevant lines fro
As far as I can tell, this is also the case with Python 3. I'm trying to return a binary data (bytes). It's not working at all.
I also tried to use base-64 encoding and I have had no success.
This is with API Gateway and Proxy Integration.
[update]
I finally realized how to do this. I enabled binary support for type */* and then returned this:
return({
"isBase64Encoded": True,
"statusCode": 200,
"headers": {
"content-type": "image/jpg",
},
'body': base64.b64encode(open('image.jpg', 'rb').read()).decode('utf-8')
})