我尝试部署一个包含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限制还是有其他方式来定义它?
答案 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云端存储中检索图像并执行处理。