3

I can find lots of information on writing directly to the output stream from an AWS Lambda function written in Java, but I can't find any information on how to get that stream in the Java AWS Lambda SDK so that I can bind the resulting inputstream to the outputstream within our API (the client of the Lambda function). Does anyone know how I can do this? All I can find in the InvokeResult is getPayload() which is a ByteBuffer. If I use this, it implies that the entire stream is loaded into the memory of the buffer before I can forward it back out of our API. We're returning PDF documents, but I guess the same applies to any binary stream.

Flow looks like:

UI --> Our API (assembles Lambda function input JSON) --> AWS Lambda Function
UI <-- Our API (directly streams Lambda response to UI - hopefully) <-- AWS Lambda Function
Richtopia
  • 360
  • 2
  • 12
  • Have you implemented your function, yet? I ask, because Lambda doesn't return binary data -- it's character data. If your payload is binary, it would need to be base64 encoded on the way out of Lambda, and your API would (presumably) need to decode it before returning it to your caller. – Michael - sqlbot Nov 04 '18 at 13:48
  • According to this https://docs.aws.amazon.com/lambda/latest/dg/java-handler-io-type-stream.html, it's binary data when the stream interface is used. Others are using it for image processing, so it must be binary, not character-based. – Richtopia Nov 04 '18 at 15:52
  • It seems you are right. This is an interesting exception to what I have always believed was a hard constraint to what AWS Lambda functions could do, regardless of language. I appreciate the correction. – Michael - sqlbot Nov 04 '18 at 16:39

0 Answers0