如何处理谷歌云终端中的帖子请求?

时间:2022-12-22 23:09:55
  @endpoints.method(InputClass,OutputClass,
                          path='apipath', http_method='POST',
                          name='something.apiname')

and my input class is

我的输入类是

class InputClass(messages.Message):
    var1 = messages.StringField(1)
    var2 = messages.StringField(2)
#Code to store image data

From the above code a service is created that is called from the form with form data. Now on the form there is file field in which user uploads a photo. Now all other form data will get stored in the input class but i don't know how to store image in input class. I mean what would be the message field to store the image data.

从上面的代码中创建一个服务,该服务从具有表单数据的表单中调用。现在,在表单上有一个文件字段,用户可以在其中上传照片。现在所有其他表单数据将存储在输入类中,但我不知道如何在输入类中存储图像。我的意思是存储图像数据的消息字段是什么。

1 个解决方案

#1


0  

Convert the photo to Base64 and send it as a String value. You can find lots of examples how to do this e.g. Base64 encoding in Python 3

将照片转换为Base64并将其作为String值发送。你可以找到很多例子如何做到这一点,例如Python 3中的Base64编码

If the photo is large you have to use Blobstore. More about uploading files to blobstore here. Once the photo is uploaded to the Blobstore you keep track of its blobKey. You can fetch or delete the photo from the Blobstore using the blob key.

如果照片很大,则必须使用Blobstore。有关将文件上传到blobstore的更多信息。将照片上传到Blobstore后,您可以跟踪其blobKey。您可以使用blob键从Blobstore中获取或删除照片。

#1


0  

Convert the photo to Base64 and send it as a String value. You can find lots of examples how to do this e.g. Base64 encoding in Python 3

将照片转换为Base64并将其作为String值发送。你可以找到很多例子如何做到这一点,例如Python 3中的Base64编码

If the photo is large you have to use Blobstore. More about uploading files to blobstore here. Once the photo is uploaded to the Blobstore you keep track of its blobKey. You can fetch or delete the photo from the Blobstore using the blob key.

如果照片很大,则必须使用Blobstore。有关将文件上传到blobstore的更多信息。将照片上传到Blobstore后,您可以跟踪其blobKey。您可以使用blob键从Blobstore中获取或删除照片。