首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >部署包含"file“类型参数的端点时出错

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

Stack Overflow用户
提问于 2017-03-28 01:50:15
回答 2查看 1.5K关注 0票数 1

我正在尝试部署一个包含file的简单端点。

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

代码语言:javascript
复制
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

但是得到以下错误:

代码语言:javascript
复制
 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参数,端点就会成功部署。这是的限制,还是有其他方法来定义它?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-03-29 01:12:20

目前不支持上传图像。

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

然后将URL传递给您的,这些端点可以从检索图像并执行处理。

票数 5
EN

Stack Overflow用户

发布于 2022-06-21 07:43:34

您也可以上传文件而不是类型文件,如下所示

代码语言:javascript
复制
- in: formData
  name: file
  description: Upload file
  type: string
  format: binary

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43059304

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档