如何使用c#从API网关获取lambda中的请求主体



我有一个API网关发布请求,要通过lambda函数将PDF文件上传到S3存储桶。内容类型是application/pdf,在它下面我将模板定义为{"content":"$input.body"}

在我的lambda函数中,我有:

public APIGatewayProxyResponse FunctionHandler(APIGatewayProxyRequest request, ILambdaContext context)
{
Console.WriteLine(request.Body);
return new APIGatewayProxyResponse
{
Body = request.Body,
StatusCode = 200
};
}

然而,当我在Postman中测试它时,在请求主体中附加一个PDF文件,内容类型为application/PDF,在lambda函数中访问的请求主体总是空的。为什么?

需要显式配置对API网关的二进制支持。

希望这就是你想要的:https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings-configure-with-console.html

最新更新