【问题标题】:How to get request body in lambda from API Gateway using c#如何使用 c# 从 API Gateway 获取 lambda 中的请求正文
【发布时间】:2020-06-24 03:37:00
【问题描述】:

我有一个 API Gateway 发布请求,通过 lambda 函数将 PDF 文件上传到 S3 存储桶。 Content-Type 是 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 文件并在 Content-Type 为 application/pdf 中对其进行测试时,在 lambda 函数中访问的请求正文始终为空。为什么?

【问题讨论】:

    标签: c# .net aws-lambda aws-api-gateway


    【解决方案1】:

    需要明确配置对 API 网关的二进制支持。

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

    【讨论】:

      猜你喜欢
      • 2022-10-14
      • 1970-01-01
      • 2016-11-09
      • 2016-03-03
      • 2020-09-12
      • 1970-01-01
      • 1970-01-01
      • 2019-06-09
      • 2020-10-01
      相关资源
      最近更新 更多