On 2/05/2013 5:54 PM, Craig Chant wrote:
Hi,
I understand that Catalyst has a known issue with delivering
authenticated files via the response mechanism.
What does the Catalyst community do to work around this problem?
If I want to read a large file from disk or collate a large CSV / XML
file and deliver it direct to the browser, how do I do this?
Though you do not say what you are currently trying do do, I'm presuming
your problem is related to trying to stuff the content into
$c->res->body or otherwise pull into stash. But what it sounds like with
large content is that you just want to stream it. $c->res will act like
a filehandle in this case, so anything expecting a filehandle will be
able to use it.
Example code:
<snip>
package Quick::Controller::Sample;
use Moose;
use namespace::autoclean;
BEGIN { extends 'Catalyst::Controller' };
sub index :Path :Args(0) {
my ( $self, $c ) = @_;
use XML::Writer;
$c->res->content_type('text/xml');
my $writer = XML::Writer->new(
OUTPUT => $c->res,
DATA_INDENT => 2,
DATA_MODE => 1
);
$writer->startTag("document");
$writer->startTag("greeting",
"class" => "simple");
$writer->characters("Hello, world!");
$writer->endTag();
$writer->endTag();
$writer->end();
}
# Override default end
sub end : Private {}
__PACKAGE__->meta->make_immutable;
1;
</snip>
Noting the override of the end() action in the controller so nothing is
passed to RenderView.
_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/