当前位置: 首页>>代码示例>>C#>>正文


C# IDocument.AppendContentStream方法代码示例

本文整理汇总了C#中IDocument.AppendContentStream方法的典型用法代码示例。如果您正苦于以下问题:C# IDocument.AppendContentStream方法的具体用法?C# IDocument.AppendContentStream怎么用?C# IDocument.AppendContentStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDocument的用法示例。


在下文中一共展示了IDocument.AppendContentStream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UploadStreamInTrunk

            private bool UploadStreamInTrunk(string filePath, Stream fileStream, IDocument remoteDocument)
            {
                if (repoinfo.ChunkSize <= 0)
                {
                    return false;
                }

                string fileName = remoteDocument.Name;
                for (long offset = fileStream.Position; offset < fileStream.Length; offset += repoinfo.ChunkSize)
                {
                    bool isLastTrunk = false;
                    if (offset + repoinfo.ChunkSize >= fileStream.Length)
                    {
                        isLastTrunk = true;
                    }
                    Logger.Debug(String.Format("Uploading next chunk (size={1}) of {0}: {2} of {3} finished({4}%)", fileName, repoinfo.ChunkSize, offset, fileStream.Length, 100 * offset / fileStream.Length));
                    using (ChunkedStream chunkstream = new ChunkedStream(fileStream, repoinfo.ChunkSize))
                    {
                        chunkstream.ChunkPosition = offset;

                        ContentStream contentStream = new ContentStream();
                        contentStream.FileName = fileName;
                        contentStream.MimeType = MimeType.GetMIMEType(fileName);
                        contentStream.Length = repoinfo.ChunkSize;
                        if (isLastTrunk)
                        {
                            contentStream.Length = fileStream.Length - offset;
                        }
                        contentStream.Stream = chunkstream;
                        lock (disposeLock)
                        {
                            if (disposed)
                            {
                                throw new ObjectDisposedException("Uploading");
                            }
                            try
                            {
                                remoteDocument.AppendContentStream(contentStream, isLastTrunk);
                                Logger.Debug("Response of the server: " + offset.ToString());
                                database.SetFileServerSideModificationDate(filePath, remoteDocument.LastModificationDate);
                            }
                            catch (Exception ex)
                            {
                                Logger.Fatal("Upload failed: " + ex);
                                return false;
                            }
                        }
                    }
                }
                return true;
            }
开发者ID:pcreignou,项目名称:CmisSync,代码行数:51,代码来源:SynchronizedFolder.cs

示例2: AppendFile

 /// <summary>
 ///  Appends the localFileStream to the remoteDocument.
 /// </summary>
 /// <returns>
 ///  The new CMIS document.
 /// </returns>
 /// <param name='remoteDocument'>
 ///  Remote document where the local content should be appended to.
 /// </param>
 /// <param name='localFileStream'>
 ///  Local file stream.
 /// </param>
 /// <param name='status'>
 ///  Transmission status where the uploader should report its appending status.
 /// </param>
 /// <param name='hashAlg'>
 ///  Hash alg which should be used to calculate a checksum over the appended content.
 /// </param>
 /// <exception cref="CmisSync.Lib.Tasks.UploadFailedException">If Upload fails</exception>
 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);
         }
     }
 }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:33,代码来源:SimpleFileUploader.cs


注:本文中的IDocument.AppendContentStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。