I am working on a Outlook Add In, and I am having a weird problem when handling office attachments in the form of docx or xlsx.
I import them to OpenKM using the following (vb.net) code:
Code: Select all
Dim fileInputStream As IO.FileStream = New IO.FileStream(tempPath & "\" & tempFilename, IO.FileMode.Open) Dim content(fileInputStream.Length) As Byte fileInputStream.Read(content, 0, fileInputStream.Length) If webservice.documentExists(openKmpath & "/" & tempFilename) = False Then webservice.createSimple(openKmpath & "/" & tempFilename, content) End If fileInputStream.Close()
webservice is an instance of OKMWebservice.
The problem is that when I try to download these documents from OpenKM, word and excel complain that they have been corrupted and they try to fix them. Excel tries some file validation repair, and Word plain refuses to open the file complaining it is corrupt. Excel eventually opens the file - and all the content is there. Word makes me recover the contents into a new file, and again everything is there.
I have carried out a byte comparison between the files before and after upload to OpenKM through my method and there is no change. Byte for byte the files are the same.
If I load the files into OpenKM through the Add Document menu option or through the Java File Uploader everything is fine. If I convert the files to the older .doc and .xls formats before I put them through my method, everything is fine.
The problem seems to be either something to do with my code, which seems simple, or the createSimple method is doing something to the files. When I view their properties in Windows, the metadata seems to have been stripped off (I mean the right click->properties->details tab information). All info apart from the creation dates is missing. The only thing I can think of is that this is triggering an Office warning about the file which manifests as a complaint about it being corrupt. Somehow the built in file upload methods manage to preserve this information, but the createSimple method does not.
All the metadata on the doc, or xml, files is also preserved by the createSimple method, it is just docx and xlsx files that seem to be affected. At present this is just an annoyance, as all the file content data is being preserved, and it just means a couple more mouse clicks when extracting a document, but I am concerned something more fundamental is wrong.