hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yannick PIERSON" <piers...@gmail.com>
Subject upload httppost
Date Mon, 21 Apr 2008 14:25:57 GMT
Hi,
I want 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/test_conf.pdf"

I started with this code :
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("
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);
...

But I get this exception :
java.net.SocketException: Software caused connection abort: socket write
error
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at
java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
        at
org.apache.http.impl.io.AbstractSessionOutputBuffer.write(AbstractSessionOutputBuffer.java:109)
        at
org.apache.http.impl.conn.LoggingSessionOutputBuffer.write(LoggingSessionOutputBuffer.java:66)
        at
org.apache.http.impl.io.ChunkedOutputStream.flushCacheWithAppend(ChunkedOutputStream.java:117)
        at
org.apache.http.impl.io.ChunkedOutputStream.write(ChunkedOutputStream.java:166)
        at
org.apache.http.entity.InputStreamEntity.writeTo(InputStreamEntity.java:85)
        at
org.apache.http.impl.entity.EntitySerializer.serialize(EntitySerializer.java:97)
        at
org.apache.http.impl.AbstractHttpClientConnection.sendRequestEntity(AbstractHttpClientConnection.java:161)
        at
org.apache.http.impl.conn.AbstractClientConnAdapter.sendRequestEntity(AbstractClientConnAdapter.java:261)
        at
org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:237)
        at
org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:119)
        at
org.apache.http.impl.client.DefaultClientRequestDirector.execute(DefaultClientRequestDirector.java:363)
        at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:500)
        at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:455)
        at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:421)


I presume that my error is in this line HttpPost httppost = new HttpPost("
http://computer_name/webdav_access/Docs/test_conf.pdf");
But which path to use ?

Thanks in advance,
Regards.

Yannick

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