Image Upload via HTTP POST/Google App Engine

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


Sponsored Links
 Hi,

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
ByteArrayOutputStream();
            query.compress(Bitmap.CompressFormat.PNG, 100, baos); //bm
is the bitmap object
            byte[] b = baos.toByteArray();

            try {
                // Add your data
                List<NameValuePair> nameValuePairs = new
ArrayList<NameValuePair>(2);
                nameValuePairs.add(new BasicNameValuePair("description",
"testtesttest"));
                nameValuePairs.add(new BasicNameValuePair("image", new
String(b)));
                httppost.setEntity(new
UrlEncodedFormEntity(nameValuePairs));
                // 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


  http://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.0.x/httpclient/src/examples/org/apache/http/examples/client/ClientGZipContentCompression.java 

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
 http://tech-droid.blogspot.com 




> >



Other Threads

1. Trouble using ListView

Hi,

I'm just trying to set the content of a List View from a String[]
array.

and i tried using the ArrayAdapter to set the List Adapter. as...

setListAdapter(new ArrayAdapter<String>(this,R.layout.mycustomlayout,
R.id.content_text_view, list);
where list is my String[] array.

mycustomlayout file is as follows....

<LinearLayout
android:orientation="Vertical"
          .............
<TextView
android:id="@+id/listtitle"
...................
/>
<TextView
android:id="@+id/list_intro"
.................
/>
<TextView
android:id="@+id/content_text_view"
.......
/>

Do tell me what i'm doing wrong.

I seem to be getting a nullpointerexception in the above mentioned
line in my code.

Thanks....

Shrikanth
--~--~---------~--~----~------------~-------~--~----~

2. Saalam kenal dan mau belajar android

Paggii semuaa,
Salaam knal utk para suhu dan teman2 disini. Mau blajar android nih. Ngga tau 
apa2.
Makasii yaa

Regards,
si...@idfoldingbike.com 
Sent from my BlackBerry
powered by Sinyal Kuat INDOSAT
--~--~---------~--~----~------------~-------~--~----~
Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group, please visit the following page:
 

3. Support for newer kernel versions

4. help me:Compile the android kernel for the Emulator

5. Help me: Compile 2.6.29 for Htc Hero

6. activity leaked a window

7. Chosse the connection interface before sending request?