我遇到了一个问题,我的API网关+ Lambda集成正在经历API网关的某种形式的内容映射。
我有一个使用Lambda代理集成的端点的API网关。
我启用了二进制媒体类型: image/jpeg映像/png映像/webp映像/*/
端点获取图像,根据使用的浏览器将其优化为jpeg或webp。
对于Firefox,它会像预期的那样返回图像/jpeg。
在Chrome中查看(返回webp文件)将返回一个方框。(所有这些都适用于弹性豆秆,所以我知道这是一个网关问题)
在Chrome中,我可以看到正在发生某种映射:
content-length: 4710
content-type: image/webp
status: 200
x-amz-apigw-id: UEG2ZE8vDoEFR8A=
x-amzn-remapped-content-length: 2580
x-amzn-requestid: 6217195f-20ae-11e9-9faf-ebf6a6f5765d
x-amzn-trace-id: Root=1-5c4b1e8f-cab2e4fd2564412ef5914509;Sampled=0值:x映射内容长度是应该返回的长度。我不知道是什么进程扭曲了数据的返回。
代理集成设置

API网关配置

发布于 2019-01-30 20:07:40
对于被困在这个问题上的其他人,我需要在我的Lambda入口点注册二进制类型,请参见下面的内容:
public class LambdaEntryPoint : Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction
{
protected override void Init(IWebHostBuilder builder)
{
// Register any MIME content types you want treated as binary
RegisterResponseContentEncodingForContentType("image/jpeg", ResponseContentEncoding.Base64);
RegisterResponseContentEncodingForContentType("image/webp", ResponseContentEncoding.Base64);
RegisterResponseContentEncodingForContentType("image/png", ResponseContentEncoding.Base64);
builder
.UseStartup<Startup>();
}
}https://stackoverflow.com/questions/54367468
复制相似问题