Image Upload via HTTP POST/Google App Engine

by KG » Mon, 02 Aug 2010 06:42:30 GMT

Sponsored Links

I'm trying to integrate Google App Engine with an Android app I've
built but am having trouble with image processing.  In the Android
app, I convert the image into a byte array and send it to App Engine
via HTTP POST to be put in a Blob.  However, even after searching
through all the examples posted, I can't figure out how to retrieve
the image and display it from the Blob (or if I even sent it to the
Blob correctly).

Help on either the Android or Google App Engine side would be greatly
appreciated.  Here's the code I'm using for the Android side:

            // Create a new HttpClient and Post Header
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost(website_url);

            ByteArrayOutputStream baos = new
            query.compress(Bitmap.CompressFormat.PNG, 100, baos); //bm
is the bitmap object
            byte[] b = baos.toByteArray();

            try {
                // Add your data
                List<NameValuePair> nameValuePairs = new
                nameValuePairs.add(new BasicNameValuePair("description",
                nameValuePairs.add(new BasicNameValuePair("image", new
                // Execute HTTP Post Request
                HttpResponse response = httpclient.execute(httppost);

            } catch (ClientProtocolException e) {
                // TODO Auto-generated catch block
            } catch (IOException e) {
                // TODO Auto-generated catch block

Thank you.


Image Upload via HTTP POST/Google App Engine

by Jenus Dong » Mon, 02 Aug 2010 11:42:48 GMT 

You can check the key of "Image", get the input stream, do it reverse
according to the sending progress.
Maybe I misunderstand your question, hehe.


Sponsored Links

Image Upload via HTTP POST/Google App Engine

by Kumar Bibek » Mon, 02 Aug 2010 20:00:08 GMT

 I think you should use the InputStreamEntity already available on
Android and attach it to your post request with the correct mime type.
This is a simple way to ensure that the request you would be sending
is correctly formed in the first place. And then you should go on and
check on the server.

-Kumar Bibek 

> >

Other Threads

1. currently running applications

Is it possible to query, which applications are currently running on a
device and especially which application the user is currently using?

2. UI background task

Here's scenario:
1. Client makes remote call to the service (returns void) and provides
a callback object
2. Service executes some long running logic on the background thread
and then uses callback object to trigger ether success or failure
which (since these manipulate visual elements) execute in
Activity#runOnUiThread block

The scenario runs fine. The question is - can I use AsyncTask to make
code less verbose (how?) and would be there any advantages in doing it
that way?

Or should I just get away from client callbacks alltogether and
execute remote service calls retrofitted to return some value within

3. zipalign and Eclipse: Does Eclipse do this automatically?

4. zipalign and Proguard

5. set transparent background of an imageview in android

6. building android from source code & running in emulator and measuring video playback performance using opencore

7. mp4 composer api