当前位置: 首页 > 知识库问答 >
问题:

通过app-engineendpointapi服务blobstore映像

吕向荣
2023-03-14
from google.appengine.api import files

def save_image(data):
  # Create the file
  file_name = files.blobstore.create(mime_type='image/png')

  # Open the file and write to it
  with files.open(file_name, 'a') as f:
    f.write('data')

  # Finalize the file. Do this before attempting to read it.
  files.finalize(file_name)

  # Get the file's blob key
  blob_key = files.blobstore.get_blob_key(file_name)
  return blob_key # which is then saved to datastore
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)

将图像添加到StuffResponseMessage

发送StuffResponseMessage到前端(android应用)

我的做法是因为我想保护我的用户的隐私。对如何做好这件事有什么想法吗?我的代码片段通常来自google developer Tutorial。

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)

resource里面有什么?

暂时还没有答案

 类似资料:
  • 在以下片段中,是blob键吗?

  • 问题内容: 我有一个带有API路由的Flask后端,可通过使用create-react-app创建的React单页应用程序访问。当使用create-react- app开发服务器时,我的Flask后端可以工作。 我想从我的Flask服务器提供内置的(使用)静态React应用程序。构建React应用会导致以下目录结构: 通过,我的意思是在构建时所产生的随机生成的字符串。 收到文件后,浏览器将发出以下

  • 我在服务器(gae)中创建数据,并希望将其存储在BlobStore中。我看到了很多关于如何实现这一点的答案给客户机一个BlobStore URL,但是没有客户机或HTTP请求:这只是一个异步任务。 > 那么我想我应该使用createUploadUrl(),而不是将此URL提供给客户机,而是通过URL获取从我的代码HTTP将数据发布给它。这看起来很奇怪,不是有另外一个API吗? 假设我想要在Blob

  • 我在寻找一种方法来备份谷歌应用程序引擎上的blobstore,以从意外删除中恢复。我希望能够同时备份datastore和blobstore,这样我就可以恢复整个系统。 我尝试的一件事是使用谷歌云存储我的blob,然后制作buckets的备份副本。但是,如果我在blobstore查看器中删除一个文件(它也在google cloud storage中删除它),然后使用gsutil从bucket备份中恢

  • 17.2 通过 systemctl 管理服务 基本上, systemd 这个启动服务的机制,主要是通过一只名为 systemctl 的指令来处理的!跟以前 systemV 需要 service / chkconfig / setup / init 等指令来协助不同, systemd 就是仅有 systemctl 这个指令来处理而已呦!所以全部的行为都得要使用 systemctl 的意思啦!有没有很

  • 问题内容: 我的项目结构如下 我试图像这样从模块(即默认模块)导入, 但事实证明。但是我可以在内部实现相同的功能。请注意,我正在同时运行和文件。 问题答案: 部署后,GAE服务/模块不会在其模块目录(文件所在的目录)之外共享 任何内容。 因此,在dir(存在的地方)上方看不到任何东西,因此看不到。但是可以,因为模型位于其目录(存在)中。 如果需要,可以在内部进行符号链接,请参阅在App Engin