部署包含“文件"类型参数的端点时出错; [英] Error deploying endpoint containing parameter of type "file"
问题描述
我正在尝试部署一个简单的终结点,其中包含类型为file
的参数.
I'm trying to deploy a simple endpoint which contains a parameter of type file
.
我将gcloud service-management deploy
命令与以下符合openapi的yaml一起使用:
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
但是出现以下错误:
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限制还是有另一种定义方式?
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 ?
推荐答案
Google Cloud Endpoints当前不支持图像上传.
Google Cloud Endpoints does not currently support uploading of images.
您可以先上传到Google Cloud Storage: https://cloud.google.com/storage/docs/json_api/v1/how-tos/upload https://cloud.google.com/storage/docs/object-basics
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
然后将URL传递到您的Google Cloud Endpoints,然后可以从Google Cloud Storage检索图像并执行处理.
And then pass the URL to your Google Cloud Endpoints, which could then retrieve the image from Google Cloud Storage and perform processing.
这篇关于部署包含“文件"类型参数的端点时出错;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!