Using contentHandling in serverless.yml

I created a serverless project on AWS and I’m trying to convert the service into a project configured by serverless framework. I already appended http event in the events property of my serverless.yml and deployed it. The API was generated in API Gateway successfully, but when I tried to post a binary file via the api, I found that it was not encoded to BASE64 format. I exported the configuration files generated by serverless.yml and AWS console page and compared them. I found that contentHandling: CONVERT_TO_TEXT was missing in the file generated by serverless framework. I tried to add contentHandling below events but didn’t got any luck. Could somebody kindly tell me the solution to append contentHandling?

1 Like

You might want to use this plugin: https://github.com/maciejtreder/serverless-apigw-binary

Note: There are two almost named similar plug-in for Binary Support - Weird!!!

Read more in detail of AWS doc for better understanding
http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings.html

Plug-ins
https://github.com/ryanmurakami/serverless-apigwy-binary>>
https://github.com/maciejtreder/serverless-apigw-binary/blob/master/index.js>>

Both works on create Stack , but not on update Stack - getting this error

============================
Serverless Error ---------------------------------------

 An error occurred while provisioning your stack: ApiGatewayDeployment1497629194364
 - The REST API doesn't contain any methods.

======================

Hello,

First of all, I am happy to see that plugin developed by me is mentioned here.

Second:

NaraGitHub, I am happy to inform you, that in the newest version, plugin is based on update action. After stack deployment it is using AWS sdk, to perform update on API gateway.

And no, this plugins are not same. The one developed by ryanmurakami is setting CONVERT_TO_BINARY on the resource. Plugin developed by me (https://github.com/ryanmurakami/serverless-apigwy-binary) is setting up general binary support (Binary Support section in API gateway settings).

You can check out the working demo here:
http://angular-universal-serverless.maciejtreder.com

PS: Everyone! Feel free to give me a star on github, as a celebration of my first post on this forum! :slight_smile:

2 Likes