5
votes

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.

2
been wondering if you have any working code on this solution? - Jacek KwiecieĊ„

2 Answers

1
votes

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.

3
votes

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.