Google Cloud Storage + App Engine签名的网址上传处理程序 [英] Google Cloud Storage + App Engine signed url upload handler

查看:163
本文介绍了Google Cloud Storage + App Engine签名的网址上传处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以在带有Google App Engine(Java)的Google云端存储中使用已签名的URL创建处理程序?

我可以在我的Android(Java)应用程序中将文件成功上传到具有签名URL的存储区中,但是在上载完成后,我没有当前的方式来执行附加代码服务器端。

我一直在讨论Blobstore API,并创建了由应用引擎中的servlet处理的上传url,但似乎无法使其在我的内部工作Cloud Endpoints App Engine项目。



另外,签名的url对我来说似乎很有利,因为我可以设置它们的到期时间。

解决方案

看起来目前唯一的方法是使用对象更改通知。其实并没有那么糟糕。



我在Cloud Endpoints App Engine项目中设置了一个servlet,并在它的 doPost()我在请求的json主体中读取并解析它,获得所需的全部信息: https://cloud.google.com/storage/docs/object-change-notification#_Type_AddUpdateDel



保留请注意文档中的警告:


由于上述重试机制,有可能多次传送
通知。确保您的
应用程序对于处理一个唯一的
通知是幂等的。


您发送通知后采取的是幂等的(例如,多次操作不会影响操作的第一个结果)

Is there any way to create a handler with signed urls in Google Cloud Storage with Google App Engine (Java)?

I can successfully upload files to buckets with signed URLs in my Android (Java) app but I have no current way of executing additional code server-side upon upload completion.

I have been messing around with the Blobstore API and by creating upload urls that are handled by a servlet in app engine but I can't seem to make it work inside my Cloud Endpoints App Engine project.

Also, signed urls seem favorable to me because I can set expiration times on them.

解决方案

Looks like the only way to do this right now is with object change notifications. Which actually isn't that bad.

I set up a servlet in my Cloud Endpoints App Engine project and in it's doPost() I read in the json body of the request, and parsing it you get all the information you need: https://cloud.google.com/storage/docs/object-change-notification#_Type_AddUpdateDel

Keep in mind this warning from the docs though:

Because of the retry mechanism above, it is possible that notifications are delivered more than once. Ensure that your application is idempotent with respect to processing a unique notification.

So make sure whatever operations you are taking after a notification is sent is idempotent (e.g. doing the operation more than once does not affect the first result of the operation)

这篇关于Google Cloud Storage + App Engine签名的网址上传处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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