使用python中的端点将图像文件上传到数据存储区?

时间:2021-12-05 21:21:46

I am trying to make a form for adding users that will store user information to my database.

我正在尝试创建一个表单来添加将用户信息存储到我的数据库的用户。

I want to upload an image file using Cloud Endpoints (python). I do not have any idea how to do it.

我想使用Cloud Endpoints(python)上传图像文件。我不知道怎么做。

What will be the input class (request class) and output class (response class)?

什么是输入类(请求类)和输出类(响应类)?

@endpoints.method(inputclass, outputclass,
                      path='anypath', http_method='GET',
                      name='apiname')"

What url will I provide in the action= form field for uploading the image? How can I then show the file?

我会在action = form字段中提供哪些网址来上传图片?那我怎么能显示文件呢?

1 个解决方案

#1


3  

You have two ways to store data files (include image file). The first one is to convert your image in base 64 format, and store it on datastore (Not the best).

您有两种方法来存储数据文件(包括图像文件)。第一种是以base 64格式转换图像,并将其存储在数据存储区(不是最好的)。

The second one, is to store your image file in Google Cloud Storage (That is the best) or the blobstore (By Google themself, there is no good reason to use Blobstore).

第二个是将您的图像文件存储在Google云端存储(这是最好的)或blobstore(由Google自己,没有充分的理由使用Blobstore)。

So you have to store, your image file to Google Cloud Storage with your endpoint: https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/?hl=fr

因此,您必须使用终端将图像文件存储到Google云端存储中:https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/?hl = fr

Personnaly, I use a servlet (App Engine) to store image in GCS. My endpoints call my servlet and pass image in parameter, and my servlet store image in GCS. It works very well =)

Personnaly,我使​​用servlet(App Engine)在GCS中存储图像。我的端点调用我的servlet并在参数中传递图像,而我的servlet在GCS中存储图像。它工作得很好=)

Hope I help you..

希望我帮你..

#1


3  

You have two ways to store data files (include image file). The first one is to convert your image in base 64 format, and store it on datastore (Not the best).

您有两种方法来存储数据文件(包括图像文件)。第一种是以base 64格式转换图像,并将其存储在数据存储区(不是最好的)。

The second one, is to store your image file in Google Cloud Storage (That is the best) or the blobstore (By Google themself, there is no good reason to use Blobstore).

第二个是将您的图像文件存储在Google云端存储(这是最好的)或blobstore(由Google自己,没有充分的理由使用Blobstore)。

So you have to store, your image file to Google Cloud Storage with your endpoint: https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/?hl=fr

因此,您必须使用终端将图像文件存储到Google云端存储中:https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/?hl = fr

Personnaly, I use a servlet (App Engine) to store image in GCS. My endpoints call my servlet and pass image in parameter, and my servlet store image in GCS. It works very well =)

Personnaly,我使​​用servlet(App Engine)在GCS中存储图像。我的端点调用我的servlet并在参数中传递图像,而我的servlet在GCS中存储图像。它工作得很好=)

Hope I help you..

希望我帮你..