I have a restful web service, and i need to be able to send an image to it from Android via HttpUrlConnection.
Currently I am converting the image to a string as follows
ByteArrayOutputStream baos=new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG,100, baos);
byte [] b=baos.toByteArray();
String temp=Base64.encodeToString(b, Base64.DEFAULT);
And sending it in a request like so (Async obviously)
url = new URL("blabla/users/1/updatePhoto/" + temp);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.connect();
This is the error I get. I'm assuming the url is just too long to work, so I'm wondering if theres a better way to do this. Thanks
java.io.IOException: unexpected end of stream on Connection{192.168.0.22:8080, proxy=DIRECT@hostAddress=192.168.0.22 cipherSuite=none protocol=http/1.1} (recycle count=0)