Getting AWS Lambda and API Gateway to support binary, 2018 edition

Sam Spilsbury
Mar 4, 2018 · 3 min read
“Crumbled building walls and ceiling on the rooftop.” by Lorenzo Bollettini on Unsplash

Step 1: Tell serverless-http to base64 encode binary content-types

const serverless = require('serverless-http');
const app = require('./server/server');
module.exports = {
handler: serverless(app),
};
const serverless = require('serverless-http');
const app = require('./server/server');
module.exports = {
handler: serverless(app, {
binary: ['image/png', 'image/jpeg', 'image/x-icon'],
}),
};

Step 2: Tell API Gateway to base64 decode encoded content

Accept: image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5

Sam Spilsbury

Written by

Masters in Computer, Communication and Information Sciences, Researcher @Aalto University, Technical Director @Jurimetrics

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade