Allow browser streaming of multimedia files

M

Michael

Hello,

I'm looking for a way to allow a client who clicks on a link the ability to
"adodb.stream" a multimedia file (mainly audio/wav) files, but the file they
would be accessing is outside the wwwroot (for security / traceability). I
don't want the "save as" box to open for streamable content. Basically I'm
trying to mimic the exact action, as if they had clicked a
www.mydomain.com/download.wav file, and allow the browser to open it up
automatically and save it if needed.

Here is the code I'm currently using to stream the audio file to the client.

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile "c:\outside_my_wwwroot\test.wav"
Response.ContentType = "audio/wav"
Response.BinaryWrite objStream.Read()
objStream.Close

I'm sure it can be done, I really just probably need the appropriate headers
to tag to page (I'm using the adodb.stream object ).

Can anyone help me out with this?

Thanks!
--Michael
 
M

Michael

I've figured it out, for those ever interested, you need to do this.

Response.AddHeader "Content-Disposition", "inline; filename=anyfilename.wav"

key is in the "inline" not "attachment", If you want to force a "save as"
box, you just have to use attachment. You'll also need to set up the
ContentType, as so

strFileType = lcase(Right(strFileName, 4))

Select Case strFileType
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "application/msword"
Case ".zip"
ContentType = "application/zip"
Case ".xls"
ContentType = "application/vnd.ms-excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
ContentType = "video/mpeg"
Case ".pdf"
ContentType = "application/pdf"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
Case ".asp"
ContentType = "text/asp"
Case Else
'Handle All Other Files
ContentType = "application/octet-stream"
End Select

Response.ContentType = ContentType
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top