如何从base64编码二进制响应中停止AWS API Gateway? [英] How to stop AWS API Gateway from base64 encoding binary responses?
问题描述
我使用AWS Toolkit中的项目模板创建了一个ASP.NET Core应用程序.我将其部署为AWS Lambda,并注意到响应中二进制文件已被base64编码.我在AWS API Gateway中添加了正确的媒体类型,如下所示.浏览器正在发送正确的接受设置.响应显示x-amzn-remapped-content-length为3346,这是实际文件大小,响应大小为4464,这是base64编码版本.
I created an ASP.NET Core app using a project template in AWS Toolkit. I deployed it as AWS Lambda and noticed the binary files are being base64 encoded in the responses. I added the proper media types in the AWS API Gateway as shown below. The browser is sending the proper Accept settings. The response is showing x-amzn-remapped-content-length of 3346 which is the actual file size and the response size is 4464 which is the base64 encoded version.
我已经看到有关在yml文件中设置"contentHandling":"CONVERT_TO_BINARY"的响应.我没有使用任何yml文件.已经使用CloudFormation模板(serverless.template)设置了项目模板.我尝试将设置放在那里,但出错了.模板在部署过程中无法理解设置,或者我将其放置在模板文件中的错误位置.
I have seen responses about setting "contentHandling": "CONVERT_TO_BINARY" in yml files. I am not using any yml files. The project template already is setup with using a CloudFormation template (serverless.template). I tried putting the setting in there but it errors out. Either the template doesn't understand the setting during deployment or I was putting it in the wrong place in the template file.
关于如何使端点无需编码即可按原样发送二进制文件的任何想法吗?
Any ideas on how I can get the endpoint to send binary files as is without encoding?
推荐答案
在终结点中"x-amazon-apigateway-integration"对象中的无服务器YML文件中,将"contentHandling"设置为"CONVERT_TO_BINARY".在API网关中检查内容类型转换
In serverless YML file in your endpoint in "x-amazon-apigateway-integration" object set "contentHandling" to "CONVERT_TO_BINARY". Check this Content Type Conversions in API Gateway
这篇关于如何从base64编码二进制响应中停止AWS API Gateway?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!