Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would I use blobstore to process android images

Can someone please clarify this for me. I am reading the developer page about the blobstore at https://developers.google.com/appengine/docs/java/blobstore/overview. I can't seem to wrap my head around the process of saving and retrieving blobs? It sounds like

  • android app would directly send an image to the blobstore
  • after saving the image, the blobstore would then return a blobkey to my backend for me to put in the datastore

Is that the process? Maybe it's because I have had a long day, but I just can't see it. If someone has an example they don't mind sharing, please post it. I just need to save images from android in the blobstore and then be able to retrieve them with blobkey or otherwise.

I have already look at

  • Upload to Appengine Blobstore in Android
  • Using Google BlobStore with an Android application
  • Android Interaction with Google App Engine Blobstore Service
  • What is the syntax to get a Blobstore upload url from Android?

For the life of me, I don't know why they are not doing it for me.

I suppose some questions are:

  • How does android know where to send the blob to? I mean, does Google distinguish between my instances of the blobstore versus other people's instances, similar to how it distinguishes my instances of the datastore? In other words could I go to app engine Applications Overview and see all the blobs that belong to my app the way I could in the datastore? I suppose a complete, working piece of code could help me see these answers.

Part of my problem could be that I have never used servlet. I am presently using Google Cloud Endpoint for my api.

like image 444
learner Avatar asked Oct 04 '22 06:10

learner


2 Answers

Actually there are two ways to upload to blobstore:

Using direct upload handler:

  • Server gets a unique one-time secret upload url via createUploadUrl(..) and sends this url to client.
  • Client uses multipart/form-data POST to upload data to this url.
  • The upside is that you can upload large files (>32mb).

Using blobstore FileService API which is deprecated and should not be used any more:

  • You create you own POST upload handler where client uploads data.
  • You use FileService API so save data to blobstore.
  • The downside is that you can upload max 32mb of data (generic GAE request limit).
  • The upside is that you have access to data so you can edit contents if needed.
like image 53
Peter Knego Avatar answered Oct 19 '22 04:10

Peter Knego


Your description of the process is correct. The only step you miss is the first: the server side calls blobstoreService.createUploadUrl(redirecturl) to generate the URL to upload to. Then the handler at redirecturl will save the blob key to the datastore.

like image 38
dragonx Avatar answered Oct 19 '22 04:10

dragonx