TransferBlob Method

Object: SoftArtisans.FileUp
Syntax: TransferBlob([in] ADOField)
Description:

This method transfers (downloads) a file from a database to the browser.

The ADOField argument 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. FileUpuses 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 of 'image' or 'text' type. This distribution includes a sample SQL script that you can use to create tables for use in uploading files. See the Setup Instructions for uploading to a database on the server.

For Microsoft Access, the column should be 'OLE Object'. You can use the sample Access database included with this distribution (in the Samples directory) for downloading and uploading files. It comes pre-populated with a record containing a Microsoft Word document.

When reading from BLOB (Binary Large OBject) fields, the ADO Recordset's cursor type should be set to adOpenStatic (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.

Note on IE 4: Internet Explorer 4 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 4, 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 modify their products to process these standard MIME headers. To work around this problem, you could set the URL to:

http://myserver/mydownload.asp?bogus=filename.ext

or

http://myserver/mydocgenerator.asp?bogus=file.doc

We recommend that you either upgrade to IE 5, which solves the problem, or use SoftArtisans XFile for downloading.

See Also: ADO.NET and TransferBlob
Examples:
ASP <%
Response.ContentType = "application/msword"

'--- Create an instance of the file download component
Set fileDownload = Server.CreateObject("SoftArtisans.FileUp")

'--- Do the transfer. Open a connection to the database. This sample
'--- uses the same Access database as in Samples/uploadmdb.
'--- That database is pre-populated with the sample.doc file.
Set rsBlob = Server.CreateObject("ADODB.RecordSet")

'--- Open Recordsets
rsBlob.Open "SimpleBlobTable", "AccessUpload", 3, 3
rsBlob.MoveFirst

'--- Download the File
fileDownload.TransferBlob rsBlob.Fields("filecol")
%>

Copyright © 2010 SoftArtisans, Inc. All rights reserved.