app-engine服务器从blobstore检索图像

时间:2022-12-22 23:10:01

In the following snippets, is resource the blob key?

在以下片段中,资源是blob密钥吗?

from google.appengine.ext import blobstore
from google.appengine.ext.webapp import blobstore_handlers
class ServeHandler(blobstore_handlers.BlobstoreDownloadHandler):
  def get(self, resource):
    resource = str(urllib.unquote(resource))
    blob_info = blobstore.BlobInfo.get(resource)
    self.send_blob(blob_info)

app = webapp2.WSGIApplication([('/', MainHandler),
                               ('/upload', UploadHandler),
                               ('/serve/([^/]+)?', ServeHandler)],
                              debug=True)

And if I wanted to call the blobstore from the server (as oppose to having an external caller call to ServeHandler), how would I do that? Basically I want my backend to retrieve the blob_key (from my datastore) and then get the image from the blob_store (or is there another way for the backend to retrieve an image from the blobstore?).

如果我想从服务器调用blobstore(与外部调用者调用ServeHandler相反),我该怎么做?基本上我希望我的后端检索blob_key(来自我的数据存储区),然后从blob_store获取图像(或者后端是否有另一种方法从blobstore中检索图像?)。

link to google tutorial: https://developers.google.com/appengine/docs/python/blobstore/overview

链接到谷歌教程:https://developers.google.com/appengine/docs/python/blobstore/overview

1 个解决方案

#1


1  

Yes, the resource is the blob_key. See the BlobInfo documentation on get.

是的,资源是blob_key。请参阅获取的BlobInfo文档。

You can read from the BlobStore directly via the BlobReader class.

您可以直接通过BlobReader类从BlobStore中读取。

#1


1  

Yes, the resource is the blob_key. See the BlobInfo documentation on get.

是的,资源是blob_key。请参阅获取的BlobInfo文档。

You can read from the BlobStore directly via the BlobReader class.

您可以直接通过BlobReader类从BlobStore中读取。