Error deploying endpoint containing parameter of type “file”

浪尽此生 提交于 2019-12-12 23:08:32

问题


I'm trying to deploy a simple endpoint which contains a parameter of type file .

I'm using the gcloud service-management deploy command with the following openapi compliant 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

But getting the following error:

 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.'

If I take the file parameter out the endpoint is successfully deployed. Is that a Google Cloud Endpoint limitation or is there another way to define it ?


回答1:


Google Cloud Endpoints does not currently support uploading of images.

You could upload to Google Cloud Storage first: https://cloud.google.com/storage/docs/json_api/v1/how-tos/upload https://cloud.google.com/storage/docs/object-basics

And then pass the URL to your Google Cloud Endpoints, which could then retrieve the image from Google Cloud Storage and perform processing.



来源:https://stackoverflow.com/questions/43059304/error-deploying-endpoint-containing-parameter-of-type-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!