-
Notifications
You must be signed in to change notification settings - Fork 359
Binary output/response? #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hey @repi - the Lambda runtime API only supports JSON, so one way or another we'll have to translate to JSON. For example, API Gateway handles binary data for lambda by base64 encoding it on the way in and expecting a base64 encoded blob out from Lambda - API Gateway takes care of decoding it before shipping it back as a binary response. Having said all this, we are working on a refactor of the runtime (#63) that exposes a new crate called |
Ok thanks. If one have has a Because today it looks like it just turned into a json text giant number array which is of course very inefficient for a large binary :) |
For now I manually specify that the |
Hi Johan! Sorry about the delay.
I think that's a reasonable workaround for now! |
Thanks! |
@repi it's unreleased but the lambda-http module handles this automatically for you. I can it's not easy to find because there hasn't been a release published yet but take a look at the body response formats supported https://github.com/awslabs/aws-lambda-rust-runtime/blob/master/lambda-http/src/body.rs. I'll put together a example soon |
@softprops ah that looks good, thanks! |
Resolving since |
When using
lambda_runtime
it seems to be hardcoded that one's lambda handler will take JSON as input and output in JSON and it serialises the structures usingserde_json
. Is it possible to configure this and esp. be able to return binary data with a specified mime type instead of "application/json"?This would be most useful for lambdas for example responding with image/png, image/jpg and other binary types.
I also tested using
lambda-runtime-client
directly as then I have control over the deserialising of the request and are able to directly output a binary blob as the response. But the header for the response is fixed to useconst API_CONTENT_TYPE: &str = "application/json";
.Have there been any thoughts of how to support and handle binary responses with other mime types?
The text was updated successfully, but these errors were encountered: