为什么我不能使用 VB.Net/dotCMIS.dll 从多个 OpenCMS 文档中获取内容流?
Why can't I get the content stream from multiple OpenCMS documents using VB.Net/dotCMIS.dll?
我正在使用 OpenCMIS dotCMIS 库从符合 CMIS 的存储库中读取文档。
我有并行的 Java/Chemistry 和 VB。Net/dotCMIS 测试程序与同一个 FileNet fncmis 存储库对话。
我可以在 Java 或 VB.Net 中连接、查询和获取文档。
问题:在 VB.Net 中,我只能读取 first 文档中的内容。第二个和后续文档给了我一个内容流……但我得到的字节恰好为零。 Java 工作正常。 VB.Net 在第一个文档后失败。
没有编译警告或运行时异常。
问题:您能看出对 DisplayDocument()
的后续调用会有零字节的任何原因吗?
我使用的是最新版本的 dotCMIS,版本 0.7。
Option Explicit On
Imports DotCMIS.Client
Imports DotCMIS.SessionParameter
...
Public Sub DisplayDocument(ByVal document As IDocument)
...
' Open stream to document content and copy to a file
Dim contentStream As DotCMIS.Data.IContentStream = document.GetContentStream()
sFilePath = "c:\temp\" & contentStream.FileName
Using fis = contentStream.Stream
Using fos = New System.IO.FileStream(sFilePath, IO.FileMode.OpenOrCreate)
Dim buffer(2048) As Byte
Do While (i = fis.Read(buffer, 0, buffer.Length) > 0)
fos.Write(buffer, 0, i)
Loop
End Using
End Using
...
问题已解决!
回想起来,它与 OpenCMIS 无关,而与 .Net 流有关:我只是忘记在打开 .Net 输出流时指定 IO.FileAccess.Write
。
这是更正后的代码:
' Open stream to document content and copy to a file
Dim contentStream As IContentStream = document.GetContentStream()
sFilePath = "c:\temp\" & contentStream.FileName
Using fis = contentStream.Stream
Using fos = New System.IO.FileStream(sFilePath, IO.FileMode.Create, IO.FileAccess.Write)
Dim buffer(2048) As Byte
Do
i = fis.Read(buffer, 0, buffer.Length)
If i > 0 Then fos.Write(buffer, 0, i)
Loop While i > 0
End Using
End Using
我正在使用 OpenCMIS dotCMIS 库从符合 CMIS 的存储库中读取文档。
我有并行的 Java/Chemistry 和 VB。Net/dotCMIS 测试程序与同一个 FileNet fncmis 存储库对话。
我可以在 Java 或 VB.Net 中连接、查询和获取文档。
问题:在 VB.Net 中,我只能读取 first 文档中的内容。第二个和后续文档给了我一个内容流……但我得到的字节恰好为零。 Java 工作正常。 VB.Net 在第一个文档后失败。
没有编译警告或运行时异常。
问题:您能看出对 DisplayDocument()
的后续调用会有零字节的任何原因吗?
我使用的是最新版本的 dotCMIS,版本 0.7。
Option Explicit On
Imports DotCMIS.Client
Imports DotCMIS.SessionParameter
...
Public Sub DisplayDocument(ByVal document As IDocument)
...
' Open stream to document content and copy to a file
Dim contentStream As DotCMIS.Data.IContentStream = document.GetContentStream()
sFilePath = "c:\temp\" & contentStream.FileName
Using fis = contentStream.Stream
Using fos = New System.IO.FileStream(sFilePath, IO.FileMode.OpenOrCreate)
Dim buffer(2048) As Byte
Do While (i = fis.Read(buffer, 0, buffer.Length) > 0)
fos.Write(buffer, 0, i)
Loop
End Using
End Using
...
问题已解决!
回想起来,它与 OpenCMIS 无关,而与 .Net 流有关:我只是忘记在打开 .Net 输出流时指定 IO.FileAccess.Write
。
这是更正后的代码:
' Open stream to document content and copy to a file
Dim contentStream As IContentStream = document.GetContentStream()
sFilePath = "c:\temp\" & contentStream.FileName
Using fis = contentStream.Stream
Using fos = New System.IO.FileStream(sFilePath, IO.FileMode.Create, IO.FileAccess.Write)
Dim buffer(2048) As Byte
Do
i = fis.Read(buffer, 0, buffer.Length)
If i > 0 Then fos.Write(buffer, 0, i)
Loop While i > 0
End Using
End Using