Premature end of Content-Length delimited message body
raulmontemayor opened this issue · 3 comments
raulmontemayor commented
No problem using org.aarboard.nextcloud.api.NextcloudConnector.downloadFile(String, String)
to directly save a file.
But if I use org.aarboard.nextcloud.api.NextcloudConnector.downloadFile(String)
:
try (InputStream in = nextcloud.downloadFile(path + "/" + fileName)) {
int bytesRead;
byte[] buffer = new byte[4096];
try (OutputStream outStream = new FileOutputStream("/Users/development/" + fileName)) {
while ((bytesRead = in.read(buffer)) != -1) {
outStream.write(buffer, 0, bytesRead);
}
outStream.flush();
outStream.close();
}
}
it fails with:
org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 2,208,611; received: 6,745)
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:140) ~[httpcore-4.4.14.jar:4.4.14]
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:118) ~[httpclient-4.5.13.jar:4.5.13]
at com.github.sardine.impl.io.ByteCountInputStream.read(ByteCountInputStream.java:44) ~[sardine-5.10.jar:5.10]
at com.github.sardine.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:50) ~[sardine-5.10.jar:5.10]
at org.apache.commons.io.input.ProxyInputStream.read(ProxyInputStream.java:62) ~[commons-io-2.8.0.jar:2.8.0]
Am I doing something wrong?
Library version: 11.5.0
Nextcloud version: 17.0.0
scaamanho commented
Same problem with:
Library version 12.0.0
Nextcloud: 22.2.2
downloadFile(String, String)
seems works in all cases, but
downloadFile(String)
only works if file downloaded is small, if file have 5k or more i get the same error show avove
SimonIT commented
The error occurs for me after updating from 11.2.0 to 11.3.0 until the newest version
valentindruon commented
Same here
Library : 12.0.4