How to send files along with parameters over http
Posted
by
achie
on Stack Overflow
See other posts from Stack Overflow
or by achie
Published on 2012-12-03T22:56:23Z
Indexed on
2012/12/03
23:04 UTC
Read the original article
Hit count: 171
I am trying to send a zipfile from my android application to our server and I keep getting a 411 length required error.
Here is the code that I am using to do that.
HttpPost post = new HttpPost("http://www.xyz.org/upload.json");
post.setHeader(C.constants.HTTP_CONTENT_TYPE, "application/octet-stream");
try {
FileInputStream fis = new FileInputStream("/data/data/org.myapp.appname/app_content.zip");
InputStreamEntity reqEntity = new InputStreamEntity(fis, -1);
post.setEntity(reqEntity);
String response = doPost(post);
Log.v(tag, "response from server " + response);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
What am I doing wrong here and may I also know how I can add more parameters with this post to send them to the server.
© Stack Overflow or respective owner