Problem Statement:- Not able to stream PDF, using AWS gateway/Lambda setup.
I've following Setup:-
Gateway API -> Lambda Function(java) -> S3
Api should stream a PDF back to the client via Lambda from S3 server. I am unable to do so.
Things tried
- 
1) On Lambda side
 
- 
- 
Use RequestStreamHandler, write PDF on OutputStream
 
- 
outputStream.write(); 
 
- 
 
- 
 
- 
Use non-proxy handler, write PDF as string to one of the output variable.
 
 
- 
 
- 
2) On Gateway Side
 
- 
 
I've tried all the permutations/combinations of these 2. However, I am not able to get it to work and documentation around this area seems poor.
When I set Base64 encoding in Lambda and on gateway side specify content handling as convert to binary, i get error, fail to conert using Base64 decode. For other combinations, I get binary data as output when I test it using gateway Test funciton, however my client(Postman, Chrome, Safari) fail to convert it to PDF
Note:- I've a workaround in place, where I create a signedURL to S3 object, and send it as redirect. However, I am trying to make it work by streaming a binary file using Lambda.
Thanks for reading such a long post. Any pointers, links in the right direction are highly appreciated.