hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yannick PIERSON" <piers...@gmail.com>
Subject httpClient upload file
Date Mon, 21 Apr 2008 15:30:22 GMT
Hi,
I need some help in order to upload a file on a IIS remote server through
webdav.

My aim is to upload the file from "c:\\temp\\conf_250206.pdf" to "
http://computer_name/webdav_access/Docs/<http://computer_name/webdav_access/Docs/test_conf.pdf>
"

I started with this code but it doesn't work :
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getCredentialsProvider().setCredentials(new
AuthScope("localhost", 80), new UsernamePasswordCredentials("admin",
"admin"));

HttpPost httppost = new
HttpPost("http://computer_name/webdav_access/Docs<http://computer_name/webdav_access/Docs/test_conf.pdf>
");

File file = new File("c:\\temp\\conf_250206.pdf");
InputStreamEntity reqEntity = new InputStreamEntity(new
FileInputStream(file), -1);
reqEntity.setContentType("binary/octet-stream");
reqEntity.setChunked(true);

FileEntity entity = new FileEntity(file, "binary/octet-stream");
httppost.setEntity(reqEntity);

HttpResponse response = httpclient.execute(httppost);
...

Must I use a servlet. If yes, why ?

Thanks.
Regards.

Yannick

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message