Im trying to send an image to a REST service using Sending images using Http Post. The post is quit informative but i get a compiling error at FileBody bin1 = new FileBody(file);
.
Error: The constructor FileBody(File[]) is undefined
Which is weird because i define it, why is this happenig and whats the solution to fixing it? Any help is greatly appreciated.
Code Source:
private class ImageUpload extends AsyncTask<File, Void, String> {
@Override
protected void onPreExecute() {
if (checkNullState() == false) {
showMyDialog();
}
}
protected String doInBackground(File... file) {
String imageDescriptionTemp = "Photo Temp Description.";
String PostRequestUri = "https://demo.relocationmw.com/ws_docmgmt/Service1.svc";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(PostRequestUri);
FileBody bin1 = new FileBody(file);
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
entity.addPart("Image", bin1);
post.setEntity(entity);
HttpResponse response = client.execute(post);
resEntity = response.getEntity();
final String response_string = EntityUtils.toString(resEntity);
if(resEntity != null){
Log.i("RESPONSE", response_string);
}else{
return null;}
}
@Override
protected void onPostExecute(String result) {
if (checkNullState() == true) {
dismissMyDialog();
}
// add location once we have that figured out.
Toast.makeText(HomeActivity.this, "Image can be viewed {Location}",
Toast.LENGTH_LONG).show();
}
protected void onProgressUpdate(Map... values) {
}