I am loading documents into our Oracle database and then retrieving them for the users to view. So far PDF, DOC, XLS, CSV, etc. all perform as expected, however; DOCX, XLSX, etc. files have one annoyingly persistent issue.
When the document is downloaded by the user and they open it you get the first in a series of messages:
The file 'thefile.docx' cannot be opened because there are problems with the contents.
Details: The file is corrupt and cannot be opened.
and then:
Word found unreadable content in 'thefile.docx'. Do you want to recover the contents of this document? If you trust the source, click Yes.
After clicking yes the file opens and all of the content appears correct. Including images, formatting, tracked changeds and comments, equations, etc.
I have tried multiple methods along these lines to no avail. I simply want the files to open without the false-positive error messages.
I am using VS2010, with the website targeted at .Net Framework 2.0.
objConn = NewOracleConnection(gstrConnectionString)
objConn.Open()
cmd = NewOracleCommand
cmd.Connection = objConn
cmd.CommandText = "select DOCUMENT_NAME,DOCUMENT_TYPE,DOCUMENT from FTP_PERMIT_DOC where PERMIT_ID='" & strPermitID & "' and AMENDMENT_ID='" & strAmendmentID & "' and DOCUMENT_ID='" & strDocumentID & "'"
dr = cmd.ExecuteReader
dr.Read()
Dim blob AsOracleBlob = dr.GetOracleBlob(2)
@
Response.Clear()
Response.ContentType = dr("DOCUMENT_TYPE")
Response.AppendHeader("Content-Disposition", "attachment;filename=" + dr("DOCUMENT_NAME"))
Response.BinaryWrite(blob.Value)
Response.End()
Response.Flush()
If anyone has any idea on how to avoid these annoying messages I would love to hear it!
-Tim
|