Posts

Showing posts with the label app-engine

Downloading image blob from Google's App Engine

Last time we have seen how to upload an image to app engine. Now its time to fetch it back. There are 2 ways to do that. 1. Using serve() 2. Using urls generate for each blob. I tried using 1st method, but it did not work. So tried out second method which did work. Following are the details of that implementation. First get the url for download for each blob. To do that you need blob key of your blobs. In my case I have saved blob keys in a separate database entity. Blob key is returned when you create new blob. String[] array = getBlobKeyByProblemId(problemId); if (array != null && array.length > 0) { String[] urls = new String[array.length]; for (int i = 0; array != null && i < array.length; i++) { ImagesService imagesService = ImagesServiceFactory.getImagesService(); BlobKey key = new BlobKey(array[i]); ServingUrlOptions options = ServingUrlOptions.Builder.withBlobKey(key).secureUrl(true); urls[i] = im...

Upload an image from Android to Google's app engine server

Recently I have started working on a project on Android. This app involves uploading few images chosen by user to the server. App engine has a document page at https://developers.google.com/appengine/docs/java/blobstore/ , but unfortunately for Android developer it is not enough. This document mentions how to upload using web client i.e. using using form in a html page. For uploading using java application we need a multipart message. We need following libs: 1. httpcore-4.3.2.jar 2. httpmime-4.3.3.jar httpcore-4.3.2.jar and httpmime-4.3.3.jar can be found at http://hc.apache.org/downloads.cgi .These jars are part of zip file containing other files. Extract the entire zip and copy these two required files in <android project>/libs. public void uploadBlobImage( String path, String link ) { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(link); try { MultipartEntity entity = new MultipartEntity(); ...