[Catalyst] Out of Memory - File delivery issue
neil.lunn
neil at mylunn.id.au
Thu May 2 09:28:57 GMT 2013
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 ) =3D @_;
use XML::Writer;
$c->res->content_type('text/xml');
my $writer =3D XML::Writer->new(
OUTPUT =3D> $c->res,
DATA_INDENT =3D> 2,
DATA_MODE =3D> 1
);
$writer->startTag("document");
$writer->startTag("greeting",
"class" =3D> "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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20130502/2439c=
b80/attachment.htm
More information about the Catalyst
mailing list