CmisSync.Lib.FileTransmission.SimpleFileUploader.AppendFile C# (CSharp) Method

AppendFile() public method

Appends the localFileStream to the remoteDocument.
If Upload fails
public AppendFile ( IDocument remoteDocument, Stream localFileStream, Transmission transmission, HashAlgorithm hashAlg ) : IDocument
remoteDocument IDocument /// Remote document where the local content should be appended to. ///
localFileStream Stream /// Local file stream. ///
transmission Transmission
hashAlg System.Security.Cryptography.HashAlgorithm /// Hash alg which should be used to calculate a checksum over the appended content. ///
return IDocument
        public virtual IDocument AppendFile(IDocument remoteDocument, Stream localFileStream, Transmission transmission, HashAlgorithm hashAlg) {
            using (var transmissionStream = transmission.CreateStream(localFileStream))
            using (var hashstream = new CryptoStream(transmissionStream, hashAlg, CryptoStreamMode.Read)) {
                ContentStream contentStream = new ContentStream();
                contentStream.FileName = remoteDocument.Name;
                contentStream.MimeType = Cmis.MimeType.GetMIMEType(contentStream.FileName);
                contentStream.Stream = hashstream;
                try {
                    return remoteDocument.AppendContentStream(contentStream, true);
                } catch(Exception e) {
                    throw new UploadFailedException(e, remoteDocument);
                }
            }
        }