13

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 ?

Can Atuf Kansu
  • 523
  • 2
  • 7
  • 16
  • You can try uploading binary data separately to S3 via AJAX. That should fix your problem. – adamkonrad Dec 19 '15 at 19:08
  • 2
    @kixorz, there are multiple reason why people stick to API Gateway, and not sending data directly to S3. In my case, I need the API to be simple and user must have API-Key to make a call to an endpoint. API Gateway simplifies that for me. – C-- May 17 '16 at 10:50
  • I know this, but for the time being you need to find a workaround. S3 is a decent solution. – adamkonrad May 17 '16 at 13:13

1 Answers1

16

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!!

jackko
  • 6,998
  • 26
  • 38