By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,992 Members | 934 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,992 IT Pros & Developers. It's quick & easy.

Allow browser streaming of multimedia files

P: n/a
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
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

"Michael" <raterus@localhost> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.