-
Notifications
You must be signed in to change notification settings - Fork 659
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
why return base64 encoded? #99
Comments
For those who's struggling the useage of binaryMimeTypes, here is my sharing. Please correct me if anything wrong. The whole thing of adding MIME types to binaryMimeTypes is for compression. e.g. you want to gzip the application/json payload. let's first quote from @brettstack : "Express response -> compression/gzip middleware (if you use it) -> aws-serverless-express (encodes to base64 if content-type is specified in binaryMimeTypes in Lambda handler) -> API Gateway (decodes base64 if content-type matches a binary mime type specified on API) -> Client" here is my little supplement for his quote.
|
Thanks. Glad you figured it out.
…On Tue, Sep 26, 2017, 4:30 AM goldenbearkin ***@***.***> wrote:
Closed #99 <#99>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#99 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABy6l7Shg71jP0mj889sBaP6_vSVgxs7ks5smOBQgaJpZM4Pj3I0>
.
|
@goldenbearkin I'm having what seem to be encoding problems service PNG image files and thought this might be related. Did you run into this -- and if so, how did you solve it? Thanks. |
Just ran into this too. I noticed that API Gateway now supports compressing response bodies which means I think you can drop this workaround. |
I am working behind some gateway that is external to aws. Is there a way to turn of the base64 encoding? |
@brettstack would be awesome if we can disable the base64 encoding and return just a json. |
@goldenbearkin as you mentioned in I am assuming if we set binary mime types correctly in API gateway, the matching types of response will be decoded from base64 to its origianl format, while I tried to set Any thoughts? |
What's the best practice so far ? I just created a new serverless express lambda, and all I get from the API is an base64 encoded string. Shouldn't Amplify API automatically handle this ? |
I ran into this problem and realized that Resources:
ExpressServer:
Type: AWS::Serverless::Api
Properties:
...
BinaryMediaTypes:
- application~1javascript
- application~1json
...
- text~1xml and Bob is now my uncle. |
@goldenbearkin how did you fixed it? |
Hi,
If I understand correctly from #64 and #66 that listing 'application/json' in the binaryMimeTypes is for gzip support.
I tried to mimic the example with a simpler version. However I got the base64 encoded return.
Below is the setting for lambda.js and app.js
I got return value of
eyJ0ZXN0aW5nIjoidGVzdGluZyJ9
instead of
{testing: 'testing'}
The text was updated successfully, but these errors were encountered: