Strangeness when delivering files to browser with ADODB.Stream

antic

Perch
Hi guys, please help I'm slowly going strange.

I've used the below method to deliver files to the browser before, but with Flash SWF files it's producing strange results. I checked the methodology with MS here:
http://support.microsoft.com/kb/q276488/

The code I use is as follows:
Code:
'Response.ContentType = "application/octet-stream"
Response.ContentType = "application/x-shockwave-flash"
Response.AddHeader "Content-Disposition", "attachment; filename=" & sFile
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile sFile
Response.BinaryWrite objStream.Read
objStream.Close
Set objStream = Nothing
There's a vague similarity with what MS recommends, which is probably my first mistake.

As you can see I've tried two different MIME types to no avail, tried others too, and "" (blank) as well. No matter what I do, instead of the browser running the SWF file as normal, it instead displays the ASCII contents of the file on the screen.

It seems to work fine with all other types of files, and I can drop the SWF file manually into the browser which works fine - so there's nothing wrong with the SWF file itself.

Has anyone had experience with this method and knows any quirks or weirdness I'm not allowing for?

Cheers all!
 
A follow-up.. interestingly enough, THIS code in .NET works, although, assumedly, it does exactly the same thing:
Code:
Dim fs As IO.FileStream
fs = IO.File.Open("d:\overview.swf", IO.FileMode.Open)
Dim bytBytes(fs.Length) As Byte
fs.Read(bytBytes, 0, fs.Length)
fs.Close()
Response.ContentType = "application/x-shockwave-flash"
Response.BinaryWrite(bytBytes)
Response.End()
argh.... well, that's one reason to rewrite this thing in .NET :) might be a problem with the ADODB.Stream object used by ASP perhaps.

If anyone knows an ASP-based solution, please let me know! :)
 
Back
Top