将图片从Android上传到Google云端存储或Google App Engine Blobstore [英] Upload image from Android to Google Cloud Storage or Google App Engine Blobstore

查看:238
本文介绍了将图片从Android上传到Google云端存储或Google App Engine Blobstore的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个GAEJ,并希望保存从Android设备和iPhone上传的图片。

为什么有两个Google服务需要使用GAEJ?



Google Blobstore
https://developers.google.com/storage/



伪代码:


  1. HttpClient一些Base64编码数据。

  2. 将图像发送到Google App Engine。

  3. 从Google App Engine中将解码图像保存到BlobStore或云存储。

  4. HttpServletResponse状态返回到Android。

我对如何执行步骤3感到困惑。



在此先感谢
Regards

解决方案

在应用程序引擎存在的时候,谷歌云存储还不存在,所以存储blob的方式是使用blobstore。现在它已经存在,他们也为谷歌云存储提供了blobstore工作的API。两者都适用于图像服务/操作。但我认为云存储也是在cdn中构建的,它服务于最近边缘的服务器,而blobstore在下载时将来自您的appengine实例。



上传到这两个工作同样的方式,从您的客户端,您需要请求一个上传url会话,然后将其直接上传到blobstore /云存储当您张贴到该网址

  send_to_client_url = blobstore.create_upload_url('/ yourHandler')
HttpClient.post文件到send_to_client_url
yourHandler接收一个blob行,然后将blobKey作为参考存储到您的数据存储区

当你到达你的处理程序时你已经上传了文件/ ios)

I have a GAEJ and would like to save images, uploaded from an Android device and iPhone.

Why is there two Google Services and wich one should be used from GAEJ?

Google Blobstore https://developers.google.com/appengine/docs/java/blobstore/

Google Cloud Storeage https://developers.google.com/storage/

Pseudo code:

  1. HttpClient some Base64 encoded data.
  2. Send image to Google App Engine.
  3. From Google App Engine Save the decoded image to BlobStore or Cloud Storage.
  4. HttpServletResponse status back to Android.

I am confused about how to do step 3.

Thanks in advance Regards

解决方案

Long time ago when app engine existed, google cloud storage doesn't exists yet so the way to store blobs is with blobstore. Now it existed they made the api for blobstore work with google cloud storage as well. Both work with image serving/manipulations. But cloud storage I think is also built in cdn which serves to closest edge server while blobstore when downloading will be coming from your appengine instance.

Uploading to either of this works the same way, from your client you need to request an upload url session where it will then be uploaded directly to blobstore/cloud storage when you post to that url

send_to_client_url = blobstore.create_upload_url('/yourHandler')
HttpClient.post file to send_to_client_url
yourHandler recieves a blob row then store blobKey to your datastore as reference

you will already have uploaded the file when it reaches yourhandler/or failed so handle appropriately on what you respond back to client(android/ios)

这篇关于将图片从Android上传到Google云端存储或Google App Engine Blobstore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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