I want to transfer file from my android application to http address.I written following code but doesnt work.The address of hhtp=192.168.0.1:8181
with username=admin
and password=blank
.
Where should i set username and password for http file transfer
String url = "http://192.168.0.1:8181";
File dir = Environment.getExternalStorageDirectory();
File file = new File(dir,DATABASE_NAME);
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
InputStreamEntity reqEntity = new InputStreamEntity(
new FileInputStream(file), -1);
reqEntity.setContentType("binary/octet-stream");
reqEntity.setChunked(true); // Send in multiple parts if needed
httppost.setEntity(reqEntity);
HttpResponse response = httpclient.execute(httppost);
//Do something with response...
Log.e("file transfer", "done");
} catch (Exception e) {
// show error
Log.e("error", e.getMessage());
}