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
In reply to Streaming data using dancer by gsiems
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |