Sorry,
a not very helpfull answer. Of course I read the API specification.
All SARDINE put() operations are atomic. Crashed uploads are not
resumed and you have to restart from start.
I tried
sardine.put(uri, new FileInputStream(file), "application/octet-stream", true, file.length());
If the connection breaks, it is not resumed.
Moreover it sets HTTP header 'content-lenght', but that's not what I need.
Solved it in the meantime:
HTTP header 'CONTENT_RANGE' is what is needed (found it in the Junit tests of SARDINE.)
To whom it may help: this is how I did it:
while bytes in stream {
...
// total size is mandatory. Should not be file.lenght() cause it allocates
the full file size immediately and you do not know where to resume.
header.put(HttpHeaders.CONTENT_RANGE, "bytes " + from + "-" + to + "/" + to );
sardine.put(uriString, new ByteArrayInputStream(byteArray) , header);
...
}
I used FileChannel and MappedByteBuffer to read the file in chunks.
Suggestions and improvements are welcome.