Posting form-data and binary data through AWS API Gateway

Can Atuf Kansu picture Can Atuf Kansu · Dec 18, 2015 · Viewed 10k times · Source

I'm trying to POST "mutlipart\form-data" to my EC2 instance through AWS API Gateway, but I couldn't find a way to this. There is a way to post data using "application/x-www-form-urlencoded" and Mapping Tamplate to convert it to JSON but still posting a binary data like an image file is missing I guess. Is there anything I'm missing ?

EDIT:

I have found another way:

I convert the image to base64 string then POST it as with content type "application/x-www-form-urlencoded". By this way I'm sending whole image as string. After I got the message I can convert it back to image in PHP. Only down side of this I could find is when I convert image to base64 its size gets a bit bigger. Other than that, I couldnt find any other downside. If there is could you please share with me ?

Answer

jackko picture jackko · Dec 19, 2015

Api Gateway team here.

Binary data isn't supported at the moment, but it's on our backlog. Several customers have requested this.

Some customers have had success using the base64 util in the mapping templates which may get it working for you: http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#util-template-reference

Other than that you'll have to wait for official support.

Edit

Binary support is finally here!!