从本地文件创建DotCMIS IContentStream?

时间:2014-06-27 02:58:42

标签: dotcmis

如何从本地文件创建DotCMIS.Data.IContentStream对象?

本教程仅介绍如何从内存中的字节数组创建一个:

byte[] content = UTF8Encoding.UTF8.GetBytes("Hello World!");
ContentStream contentStream = new ContentStream();
contentStream.FileName = "hello-world.txt";
contentStream.MimeType = "text/plain";
contentStream.Length = content.Length;
contentStream.Stream = new MemoryStream(content);

1 个答案:

答案 0 :(得分:0)

Stream实际上是.NET的标准System.IO.Stream,所以这里是如何从本地文件创建DotCMIS IContentStream:

ContentStream contentStream = new ContentStream();
contentStream.FileName = "hello-world.txt";
contentStream.MimeType = "text/plain";
contentStream.Stream = File.Open("hello-world.txt", FileMode.Open);
contentStream.Length = contentStream.Stream.Length;