Opening BLOB from DB as Attachment
· I'm storing attachments in a Binary Large Object (BLOB) field in a table in a database.
· I also store the MimeType.
· I want to open them.
· I list the attachments for the user to peruse, with a HyperLink under the name.
· The hyperlink opens a new blank window and redirects to a blank ASPX page.
· I also pass the Attachment ID to the new page.
· The ASPX page has a Page_Load event.
· The Page_Load event gets the record and Binary Writes the byte() to the Response.
· Also, I envisage that if it was a spreadsheet, I want to launch Excel.
· This works for JPG.
· But didn't work for a text file.
· I haven't tried PDF yet, for instance and the text file I chose was a .reg file so that might not have been a wise test!
· First I get a debug window
· Second the browser says 'The XML page cannot be displayed'
· 'Invalid at the top level of the document'
· Me.Response.AddHeader('Content-Disposition', 'inline;filename=' & fileName)
· Now the browser asks if I want to run or save the .reg file.
· I must specify the filename, even though I’m not loading the response from an actual file (but from a Memory Stream).
· This works for XLS, PDF, and JPG.
· I haven’t tried ZIP yet.
Add a comment
Please note: comments that are inappropriate or promotional in nature will be deleted.
E-mail addresses are not displayed, but you must enter a valid e-mail address to confirm your comments.
Are you a registered Geekzone user? Login to have the fields below automatically filled in for you and to enable links in comments. If you have (or qualify to have) a Geekzone Blog then your comment will be automatically confirmed and shown in this blog post.