android - how to transfer the curl command to http post request -


i using facebook object api upload images facebook staging service. api document here http://developers.facebook.com/docs/opengraph/using-object-api/

in doucement, uses curl upload image:

curl -x post https://graph.facebook.com/me/staging_resources -f file=@images/prawn-curry-1.jpg -f access_token=$user_access_token

how can achieve same function using http post request in android app?

thanks lot!

string uri = "https://graph.facebook.com/me/staging_resources"; httpresponse response = null; try {             httpclient client = new defaulthttpclient();     httppost post = new httppost(uri);     multipartentity postentity = new multipartentity();     string picpath = (uri.parse(picuristr)).getpath();     file file = new file("/data/local/tmp/images.jpg");     postentity.addpart("file", new filebody(file, "image/jpeg"));     postentity.addpart("access_token", new stringbody("your access token string here"));     post.setentity(postentity);     response = client.execute(post); } catch (clientprotocolexception e) {     log.d(tag, "exception");     e.printstacktrace(); } catch (ioexception e) {     log.d(tag, "exception");     e.printstacktrace(); }     httpentity responseentity = response.getentity(); if (responseentity== null) {     log.d(tag, "responseentity null");     return ""; } 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -