public void DownloadFile(
IDocument remoteDocument,
Stream localFileStream,
Transmission transmission,
HashAlgorithm hashAlg,
UpdateChecksum update = null)
{
{
byte[] buffer = new byte[8 * 1024];
int len;
while ((len = localFileStream.Read(buffer, 0, buffer.Length)) > 0) {
hashAlg.TransformBlock(buffer, 0, len, buffer, 0);
}
}
long? fileLength = remoteDocument.ContentStreamLength;
// Download content if exists
if (fileLength > 0) {
long offset = localFileStream.Position;
long remainingBytes = (fileLength != null) ? (long)fileLength - offset : this.ChunkSize;
try {
do {
offset += this.DownloadNextChunk(remoteDocument, offset, remainingBytes, transmission, localFileStream, hashAlg);
} while(fileLength == null);
} catch (DotCMIS.Exceptions.CmisConstraintException) {
}
} else {
transmission.Position = 0;
transmission.Length = 0;
}
hashAlg.TransformFinalBlock(new byte[0], 0, 0);
}