通过 AWS API Gateway 发布表单数据和二进制数据 [英] Posting form-data and binary data through AWS API Gateway

查看:22
本文介绍了通过 AWS API Gateway 发布表单数据和二进制数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 AWS API Gateway 将mutlipartform-data"POST 到我的 EC2 实例,但我找不到解决此问题的方法.有一种方法可以使用application/x-www-form-urlencoded"和映射模板来发布数据以将其转换为 JSON,但我猜仍然缺少像图像文件这样的二进制数据.有什么我遗漏的吗?

I'm trying to POST "mutlipartform-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 ?

我找到了另一种方法:

我将图像转换为 base64 字符串,然后将其作为内容类型application/x-www-form-urlencoded"发布.通过这种方式,我将整个图像作为字符串发送.收到消息后,我可以将其转换回 PHP 中的图像.我能找到的唯一缺点是当我将图像转换为 base64 时,它的大小会变大一点.除此之外,我找不到任何其他缺点.如果有的话可以分享给我吗?

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 ?

推荐答案

Api Gateway 团队在这里.

Api Gateway team here.

目前不支持二进制数据,但它在我们的待办事项中.有几个客户要求这样做.

一些客户在映射模板中成功使用了 base64 实用程序,这可能会为您工作:http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#util-template-reference

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.

编辑

二进制支持终于来了!!

这篇关于通过 AWS API Gateway 发布表单数据和二进制数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆