用GCS替换BlobStore上传处理程序 [英] Replacing BlobStore Upload Handler with GCS

查看:159
本文介绍了用GCS替换BlobStore上传处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据Blobstore文档中的建议,我正在考虑用GCS替换Blobstore API的用法。

据我所知,允许用户上传文件的正确方法似乎是向他们传递签名的URL,以便他们可以上传数据。 我缺少的是Blobstore API有一个UploadHandler,它允许您在文件上传时执行一些操作(例如,将元数据存储在数据库中),甚至可以返回对用户的上传请求的响应。



GCS有类似的东西吗?那里推荐的方法是什么?依靠用户通知应用程序已完成上传文件似乎很容易出错。

对象变更通知表示最接近blobstore API上传处理程序的GCS概念。在该文档的最后,有一个GAE应用程序使用示例。



然而,通过手动 gsutil 来完成控制对象更改通知注册c $ c> invocations,因此使用起来可能有点棘手。

顺便说一句,我认为实际的存储空间,而不是API本身已被弃用。或者至少这是我对Blobstore Python API的解释概述:


注意:您应该考虑使用< a href =https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/ =nofollow noreferrer> Google Cloud Storage ,而不是Blobstore来存储Blob数据。


就我个人而言,我现在坚持使用blobstore API,至少在发布实际 API 弃用日期和/或积极弃用警告开始流动 - 其他选项可能会变得可用。


I'm looking at replacing our usage of the Blobstore API with GCS, per the recommendation in the Blobstore docs.

As far as I can tell, the right way to allow a user to upload a files seems to be to pass them a signed URL where they can upload their data.

The piece I'm missing is that the Blobstore API has an UploadHandler, which allows you to perform some actions when a file has been uploaded (e.g. store metadata in a database), and even return a response to the user's upload request.

Is there something similar for GCS? What is the recommended approach there? Relying on the user to notify the app that it has finished uploading a file seems prone to errors.

解决方案

The Object Change Notification represents the GCS concept that comes closest to the blobstore API upload handler. At the end of that doc there is a GAE app usage example.

However controlling the Object Change Notifications registrations is done via manual gsutil invocations, so it may be a bit tricky to use.

BTW, I think the actual storage, not the API itself is being deprecated. Or at least that's my interpretation of the Blobstore Python API Overview note:

Note: You should consider using Google Cloud Storage rather than Blobstore for storing blob data.

Personally I'm sticking with the blobstore API for now, at least until an actual API deprecation date is published and/or active deprecation warnings start flowing - other options may become available by then.

这篇关于用GCS替换BlobStore上传处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆