0

I'm trying to implement a function, which allows from android image gallery share image to my webview application and upload it to the server.

E.g. I'm browsing through my android image gallery, on a specific image I click "share" button, then in a "Share via" window I select my webview application, which opens a specific view with packages list, then I select a package and the image is uploaded to the server with the selected package's id.

What I've done so far is getting an image from intent and opening my web application's specific view (which shows packages list) through webview.

My question is what is the best way of transferring an image to my web application?

Currently I'm thinking of encoding image into base64 and transferring it via url parameter, e.g. webview.loadUrl("http://www.dummyurl.com/ImageUpload?image=0M8R4KGxGuEA..."), but I guess it's not the best idea because of the url length limitations..

  • http://androidexample.com/Upload_File_To_Server_-_Android_Example/index.php?view=article_discription&aid=83&aaid=106 – Rohit May 20 '14 at 09:52
  • Rohit, reviewed code in this link, but I think, that it's not helpful, because before uploading an image to a server I must open a webview with my web application's view, where I can search for a specific package and after selecting a package, an image must be uploaded to a server with a selected package id.. – user3232395 May 20 '14 at 10:10
  • http://stackoverflow.com/questions/11724129/android-webview-file-upload – Rohit May 20 '14 at 10:12

1 Answers1

0

What about making a POST request to your server with the image encoded in base64 encoding?

riggaroo
  • 2,584
  • 20
  • 34
  • 1
    If this is an attempt at answer, add some more explanation, otherwise it should be a comment. – vjdhama May 20 '14 at 09:53
  • I've tried to implement it by using this [example](http://apachejava.blogspot.com/2011/05/post-params-with-android-webview.html) but my application hangs with no exception on this line: HttpResponse response = httpclient.execute(httppost); Any ideas what to do? – user3232395 May 20 '14 at 15:00
  • Is that line being called in an AsyncTask or loader? You cant do network operations on a main thread. – riggaroo May 21 '14 at 06:44