Class: SoftArtisans.FileUp
Method: TransferBlob ([in] recordset("column-name"))
Description: This method transfers (downloads) a file from a database to the browser.
The recordset must point to a valid ADO Field object that supports the GetChunk method. Any OLEDB provider that supports the GetChunk method can be used with TransferBlob. SA-FileUp uses late binding to find the GetChunk method of the recordset member and writes the data that way.
For Microsoft SQL Server, the column should be 'image' type. There is a sample SQL script included with this distribution that can be used to create tables for use in downloading and uploading files.
For Microsoft Access, the column should be 'OLE Object'. There is a sample Access database included with this distribution that can be used for downloading and uploading files. It comes pre-populated with a record containing a Microsoft Word document.
When reading from blob fields, the ADO Recordset's cursor type should be equal to 3.
Typically, you set the Content (MIME) type before executing this method.
The data is sent exactly as stored, with no interpretation and no Unicode to Multi-byte conversion.
Special note for Internet Explorer users: IE does not recognize MIME types supplied by the web server. Unfortunately, this does not comply with the HTTP protocol. Instead, IE uses the extension found at the end of the URL to determine the MIME type. So to download to IE, you must "fool" it with a bogus extension at the end of your URL. Also, IE ignores the MIME-standard content-disposition header that allows the web developer to pre-set the filename contained the user's Save Dialog box. Perhaps with enough grassroots support, Microsoft will accept to process these standard MIME headers. An example workaround would be:
http://myserver/mydownload.asp?bogus=filename.ext
or
http://myserver/mydocgenerator.asp?bogus=file.doc
Example:
<%
Response.ContentType = "application/msword"
'---
'--- Instanciate the file download component
'---
Set download = Server.CreateObject("SoftArtisans.FileUp")
'---
'--- Do the transfer. Open a connection to the database. This sample
'--- uses the same Access database as in the Upload to Database examples.
'--- That database is pre-populated with the sample.doc file.
'---
set rsBlob = Server.CreateObject("adodb.recordset")
set upl = Server.CreateObject("SoftArtisans.FileUp")
'Open Recorsets
rsBlob.Open "SimpleBlobTable", "AccessUpload", 3 , 3
rsBlob.MoveFirst
upl.TransferBlob rsBlob.Fields("filecol")
... %>