0

I am using aws lambda with an application load balancer. I have been fighting to figure out why I am getting only a piece of my content (a few bytes).

I am try to return a PDF file as binary data. This works local and it works when my application is deployed to ec2 or anywhere other than lambda.

I have looked at answers like this one AWS Lambda fails to return PDF file

but these answers are all discussing lambda settings in regards to API gateway. I am not using API gateway I am using the application load balancer. Any ideas?

Rich Wandell
  • 123
  • 1
  • 6

1 Answers1

0

Found the answer! I am using serverless-http with express. I needed to add the binary parameter for my return content type.

const serverless = require('serverless-http');
const app = require("./index");
const handler = serverless(app, {
  binary: ['application/pdf']
});
exports.handler = async (event, context) => {
  return  await handler(event, context);
};
Rich Wandell
  • 123
  • 1
  • 6