错误部署包含类型的“文件”参数端点(Error deploying endpoint contain

2019-09-28 11:22发布

我想部署一个简单的终端包含一个类型的参数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参数超出端点成功部署。 那是谷歌云端点限制或有另一种方式来界定呢?

Answer 1:

谷歌云端点目前不支持图像上载。

你可以上传到谷歌云存储第一: https://cloud.google.com/storage/docs/json_api/v1/how-tos/upload https://cloud.google.com/storage/docs/object-basics

然后将URL传递到您的谷歌云终端,然后可以检索来自谷歌云存储的图像,并进行处理。



文章来源: Error deploying endpoint containing parameter of type “file”