部署包含" file"类型参数的端点时出错

时间:2017-03-28 01:50:16

标签: google-cloud-endpoints gcloud openapi google-cloud-endpoints-v2

我尝试部署一个包含parameter of type file的简单端点。

我使用gcloud service-management deploy命令与以下openapi兼容的yaml:

swagger: "2.0"

info:
  description: "Image API"
  title: "Image API"
  version: "v1"

host: "image-api.endpoints.myproject.cloud.goog"
basePath: "/v1"

schemes:
- "https"

paths:
  "/images":
    post:
      description: "Adds an image"
      operationId: "add"
      consumes:
      - "multipart/form-data"      
      produces:
      - "application/json"
      responses:
        201:
          description: "An image create response"
          schema:
            $ref: "#/definitions/ImageResponse"
      parameters:
      - name: filepath
        in: formData
        required: true
        type: string
      - name: image
        in: formData
        required: false
        type: file

definitions:
  ImageResponse:
    type: object
    properties:
      id:
        type: string
      url:
        type: string
      thumbnail_url:
        type: string

但是收到以下错误:

 ERROR: unknown location: http: repeated message field 'google.protobuf.Struct.fields' referred to by message 'AddRequest' cann
ot be mapped as an HTTP parameter.
 ERROR: unknown location: http: cyclic message field 'google.protobuf.Struct.FieldsEntry.value' referred to by message 'AddRequ
est' cannot be mapped as an HTTP parameter.
 ERROR: unknown location: http: cyclic message field 'google.protobuf.ListValue.values' referred to by message 'AddRequest' can
not be mapped as an HTTP parameter.'

如果我取出file参数,则端点成功部署。 这是Google Cloud Endpoint限制还是有其他方式来定义它?

1 个答案:

答案 0 :(得分:4)

Google Cloud Endpoints目前不支持上传图片。

您可以先上传到Google云端存储: https://cloud.google.com/storage/docs/json_api/v1/how-tos/upload https://cloud.google.com/storage/docs/object-basics

然后将网址传递给您的Google Cloud端点,然后Google端点可以从Google云端存储中检索图像并执行处理。