Answer the question
In order to leave comments, you need to log in
Why can't upload the file to the server?
I'm trying to upload a file to a server that I'm connecting to via the WebDAV protocol.
It turns out to upload small files. But files in the region of 50KB (+ -5KB) will most likely not be sent (but they can, if it doesn’t have to). Files with a large weight, respectively, are not transferred at all.
Most common mistake:
Exception in thread "main" java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
Exception in thread "main" java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
byte[] data = getDataForRequest();
//ByteArrayEntity byteArrayEntity = new ByteArrayEntity(data);
BasicHttpEntity entity = new BasicHttpEntity();
HttpPut httpPut = new HttpPut(file);
//httpPut.setEntity(new BufferedHttpEntity(byteArrayEntity));
ByteArrayInputStream bis = new ByteArrayInputStream(data);
entity.setContent(bis);
entity.setContentLength(data.length);
httpPut.setEntity(new BufferedHttpEntity(entity));
setCommonHeaders(httpPut);
HttpResponse response = getClient().execute(HTTP_HOST, httpPut);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question