Allow browser streaming of multimedia files

Discussion in 'ASP General' started by Michael, Jan 26, 2004.

  1. Michael

    Michael Guest

    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
    Michael, Jan 26, 2004
    #1
    1. Advertising

  2. Michael

    Michael Guest

    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:%...
    > 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
    >
    >
    Michael, Jan 26, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MiniMe
    Replies:
    0
    Views:
    435
    MiniMe
    Mar 27, 2006
  2. Luc The Perverse

    Multimedia

    Luc The Perverse, Oct 23, 2005, in forum: Java
    Replies:
    8
    Views:
    515
    Andrew Thompson
    Oct 23, 2005
  3. Josh
    Replies:
    1
    Views:
    293
    Terry Reedy
    Dec 6, 2003
  4. Jeff
    Replies:
    2
    Views:
    924
    clintonG
    Sep 19, 2006
  5. Ryan Taylor
    Replies:
    1
    Views:
    668
    Ryan Taylor
    Sep 9, 2004
Loading...

Share This Page