Hi! Wondering if anyone out there can help me on this. I am attempting to enchance an existing web app that I've written in C#. I have an application that allows users to listen to mp3 files off a server using Winamp/RealAudio/MediaPlayer. Currently, the app
allows users to listen to mp3s by reading a playlist file (*.m3u ..etc..) downloaded from the web server from a Response.redirect . Now, what I want to do is to elimate any creation/saving of playlist files on the web server from the app and have a user stream/download
text as a file to user's browser (no file present). I know this can be done but would like some guidance on the code to do this. Thank you for any assistance out there.
Take a look at the
MemoryStream class. Currently we use it to generate images and stream them to the client. No images are actually saved on the disk so we don't have to worry about cleaning up temporary files. MemoryStream has a very helpful method---WriteTo (). It writes
stream contents to another stream. In our case we redirect our temporary image right to the response stream:
MemoryStream memStream = new MemoryStream ((byte [])arr); memStream.WriteTo (app.Context.Response.OutputStream); memStream.Close (); I think you've got the rest in place already---setting up the correct Response.ContentType and Response.StatusCode.
I would also recommend using the follow code as well as the memory stream Response.Content-Type = "audio/x-mpegurl" Response.AddHeader("content-disposition","attachment: filename=filename.m3u") The top line tells the browser to treat the file is receives as
an audio file even though it requested a file with an aspx extension. Then second line tells it to keep the file as its own distinct file and not to display it inline in the browser.
The problem you will have with this, is if you are creating dynamic playlists Media player 9 will disallow the expanding of playlists.... I've ran across this as it was added as a "feature" for content providers.... It is a really annoying bug, I'm working
on writing a HTTPHandler to see if i can get this working....
Hi, I am implementing a similar project with images. I want to make images available for user to d/l with different DPI options. I am wondering how I can let user to specify the download path? As Milan’s post, I am trying the MemoryStream but still not sure
how it works. Any help will be greatly appreciated. Thanks,
None
0 Points
3 Posts
Stream/download Text as File to browser
Mar 25, 2004 11:49 AM|mki1189|LINK
Member
130 Points
293 Posts
Re: Stream/download Text as File to browser
Mar 25, 2004 05:06 PM|MilanNegovan|LINK
MemoryStream memStream = new MemoryStream ((byte [])arr); memStream.WriteTo (app.Context.Response.OutputStream); memStream.Close ();
I think you've got the rest in place already---setting up the correct Response.ContentType and Response.StatusCode.http://www.AspNetResources.com
ASP.NET With Emphasis On Web Standards
None
0 Points
31 Posts
Re: Stream/download Text as File to browser
Apr 01, 2004 01:10 PM|goblyn27|LINK
None
0 Points
1 Post
Re: Stream/download Text as File to browser
Apr 13, 2004 12:21 PM|caseys|LINK
None
0 Points
14 Posts
Re: Stream/download Text as File to browser
Apr 13, 2004 08:12 PM|rliu5|LINK