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();
- Tried Setting Base64 encoding using following
- AWS Base64 Utility
- java.util Base64 Utility
- apache Base64 utility
- Send Byte[] without encoding
- Use non-proxy handler, write PDF as string to one of the output variable.
- Tried Setting Base64 encoding using following
- AWS Base64 Utility
- java.util Base64 Utility
- apache Base64 utility
- Send Byte[] without encoding
- 2) On Gateway Side
- Set Proxy integration
- Remove Proxy integration
- Tried Set Content Handling using
- Passthrough
- Convert to Binary
- Convert to String
- Set headers
- Content-Type = 'application/pdf'
- Content-Disposition = 'attachment; filename="nameofpdffile.pdf"'
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
Kindly help me out in this case.