1

我一直在尝试在 API Gateway 中创建一个方法,将传入请求的主体放入 S3 存储桶中的文件/对象中。但是我希望该方法每次都创建一个新文件(因此是一个具有新名称的文件),而不是覆盖前一个文件。但我一直在努力寻找一种方法来做到这一点。有人有任何建议/想法吗?诸如时间戳或序列号(或两者)之类的东西用作路径覆盖中的变量,以便它成为 s3 文件的名称。我查看了使用的建议,X-Amzn-Trace-Id但它似乎在Path override中不可用。还有什么我可以尝试的吗?也许在 Swagger 中有什么东西?我想使用 API Gateway 来实现它(避免使用 lambda 作为额外的步骤),以防止我们的架构变得过于复杂。提前致谢!

4

1 回答 1

0

您可以将 设置X-Amzn-Trace-Id为方法参数,然后将该参数映射到 S3 路径上的集成参数作为对象名称。

例子:

---
swagger: "2.0"
info:
  version: "2017-12-04T23:03:26Z"
  title: "API"
host: "xxxx.execute-api.us-east-1.amazonaws.com"
basePath: "/dev"
schemes:
- "https"
paths:
  /:
    post:
      produces:
      - "application/json"
      parameters:
      - name: "X-Amzn-Trace-Id"
        in: "header"
        required: false
        type: "string"
      responses:
        200:
          description: "200 response"
          schema:
            $ref: "#/definitions/Empty"
      x-amazon-apigateway-integration:
        credentials: "arn:aws:iam::178779171625:role/api-gate-way"
        responses:
          default:
            statusCode: "200"
        requestParameters:
          integration.request.path.traceid: "method.request.header.X-Amzn-Trace-Id"
        uri: "arn:aws:apigateway:us-east-1:bucketName.s3:path/{traceid}"
        passthroughBehavior: "when_no_match"
        httpMethod: "PUT"
        type: "aws"
definitions:
  Empty:
    type: "object"
    title: "Empty Schema"
于 2017-12-04T23:11:17.657 回答