I'm upgrading an app to API 23 where org.apache.http
is deprecated.
My current (deprecated) code looks like this:
HttpClient httpClient = new DefaultHttpClient();
File file = new File(attr.Value);
String url = server_url;
HttpPost request = new HttpPost(url);
FileEntity fileEntity = new FileEntity(file, "image/png");
request.setEntity(fileEntity);
HttpResponse response = httpClient.execute(request);
String output = getContent(response.getEntity().getContent());
I've found some suggestions to how this should be done using HttpURLConnection
, but they are all much more complex then the current solution (which cannot be used anymore). I'm talking about many lines of code for executing the same functionality as the above.
Examples are: this page and this page
Does anyone have a good solid shorter solution for that?