If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Forced download of binary data

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-02-04, 21:58
cwford cwford is offline
Registered User
 
Join Date: Dec 2004
Posts: 1
Unhappy Forced download of binary data

I'm storing documents as BLOBs in an Access db and downloading them to users on demand after they log in. I use the following code to store the docs to my database:

Code:
	
var objStream = Server.CreateObject("ADODB.Stream");
with (objStream)
{
	Type = adTypeBinary;
	Open;
	LoadFromFile ( Server.MapPath(FileName) );
	rs( "Doc" ) = Read( adReadAll );
}
Works great!! But I don't understand why the following download code works:

Code:
with (objStream)
{
	Type = adTypeBinary;
	Open();
//      Write ( rs( "Doc" ).value );
	Response.ContentType = "application/pdf";
	Response.AddHeader ("Content-Disposition", "attachment; filename=\"" + FileName + "\"");
	Response.AddHeader ( "Content-Length", rs("Document").ActualSize );
//	Response.BinaryWrite ( Read(adRealAll) );
	Response.BinaryWrite ( rs("Doc").value );
It seems like the two statements I commented out should work, but the only way I could get the download to work (after 8 hrs of hair pulling), was to do the BinaryWrite directly from the db field object, and then, only if I'd created and opened an ADODB Stream first.

Can any of you ASP/DB gurus tell me what's going on here?

TIA

Clyde Ford
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On