Zach Zach - 6 months ago 30
Android Question

How can I upload an thumbnail image (blob) at the same time as an Entity into a datastore in google app engine?

I Just started using google app engine today, and I have fallen in love with endpoints. I made one very easily that will store an object in the datastore that just has a few string values. But I also want a small thumbnail image to go along with that datastore entity. I understand how to upload blobs from android using an HttpServlet. I was thinking of using the id of the datastore entity as the image's name in the blobstore, but I dont know how to connect the two events since I would upload the Entity to the datastore, and then the blob after that request. Does anyone know how I can get an image in the blobstore somehow connected to the entity in the datastore so when I access the datastore i can also recall the blob associated with it. Any help would be greatly appreciated!



Well you can use ImageService API in GAE to serve your images of different sizes and also you can apply various transformations on those images.

I am sharing you some code as well below so you will understand how I am serving the image urls using the stored blobkey.

String blobKeyString = blobKey.getKeyString();   // Returned value of blobkey when upload is done.
ImagesService services = ImagesServiceFactory.getImagesService();
ServingUrlOptions serve = ServingUrlOptions.Builder.withBlobKey(blobKey);
String imageUrl = services.getServingUrl(serve);