gsiems has asked for the wisdom of the Perl Monks concerning the following question:
Dear monks,
I have a web-app written using Dancer (version 1.310) that, so far, works beautifully. However, I need to add a route that returns large datasets from a database. Because the datasets are too large to just "run query, grab results, return them" I'm looking at using streaming instead and am having issues getting things to work.
I'm using the following test snippet that uses a simple loop to simulate doing the database retrieval and things aren't working.
get '/test_download' => sub { return send_file ( 'data.csv', streaming => 1, callbacks => { override => sub { my ( $respond, $response ) = @_; my $writer = $respond->(200, [ 'Content-Disposition' = +> 'attachment; filename="data.csv"' ] ); for ( 0 .. 100) { my $line = join ',', $_, qw(1 2 3 foo bar baz 47 3 +.14159); $writer->write ($line . "\n"); } }, }, ); };
The error that I'm getting is: Can't call method "streamed" on an undefined value at /opt/restful/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/Dancer.pm line 452.
Any ideas what's wrong here?
Thanks
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Streaming data using dancer
by Anonymous Monk on Mar 14, 2013 at 19:51 UTC | |
by gsiems (Deacon) on Mar 14, 2013 at 21:10 UTC | |
by Anonymous Monk on Mar 14, 2013 at 21:25 UTC | |
by gsiems (Deacon) on Mar 14, 2013 at 21:26 UTC | |
by Anonymous Monk on May 10, 2013 at 03:18 UTC |