Hi Thomas, Check out the code associated with the 2006 advent calendar entry entitled 'streaming mp3s with Catalyst'
http://www.catalystframework.org/calendar/2006/15 It's a little more involved, in that it handles 'range' requests - but the main portion of the mp3 sending should work for you, you'd just have to add a byte counter and compare when the writing is finished if all the data was sent or not. The code you are interested in is lib/Streaming.pm - 'sub mp3 : Local' That should get you most of what you need with some well chosen hackery. As an aside - I don't know what you are doing with this - but in terms of charging based on whether the file was downloaded in it's entirety - with mp3s you can drop off the end usually without it affecting playback much, if at all. In other words - expect that people will figure out the billing method and stop the download just a few bytes shy of the end of the file to avoid paying. (I've seen automated bookmarklet things that do just that) Just something to be aware of. Jay On Mar 11, 2007, at 9:26 AM, Thomas Klausner wrote:
Hi! I need to figure out if a user aborted a longish download. (some background: Users can download a limited amount of mp3s. If the download doens't work for some reason, they must not be "charged") In our old plain mod_perl 1.x handlers, I had something like: $r->send_fd($fh); if ($r->connection->aborted) { # do stuff if user aborted download } Now, using Catalyst (on mod_perl 2.x), I'm doing this to send the file: $c->res->body( $fh ); But how do I figure out if the download was successfull? I didn't find anything in the docs (but a RTFM-answer is appreciated, if I missed the right piece of codocumentation). Thanks! -- #!/usr/bin/perl http://domm.zsi.at for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/} _______________________________________________ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/ catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
--- "May we not return to those scoundrels of old, the illustrious founders of superstition and fanaticism, who first took the knife from the altar to make victims of those who refused to be their disciples." - Voltaire _______________________________________________ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/