3

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

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.

Community
  • 1
  • 1
learner
  • 11,490
  • 26
  • 97
  • 169

2 Answers2

3

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.
tomrozb
  • 25,773
  • 31
  • 101
  • 122
Peter Knego
  • 79,991
  • 11
  • 123
  • 154
1

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.

dragonx
  • 14,963
  • 27
  • 44
  • Is that url set forever or is it dynamic? As in does the android app need to call for it each time it needs to save a blob or an I get it once and then store it on the client and use it each time I need to send a blob? – learner Apr 27 '13 at 04:21
  • it's dynamic. That function creates a new url for each blob. I'm not sure if Endpoints has a specific way to deal with it, but the general case with Blobstore is that you need to use createUploadUrl() each time you want to upload something to Blobstore. – dragonx Apr 27 '13 at 04:27
  • @dragonx when blobstore calls server thru callback url, how does the server know which user that callback is for? – Katedral Pillon Apr 27 '13 at 05:20