Hi Guys,
Just wanted to update as I have found a resolve.
Initial I wanted to try write direct to the file in the model building the CSV
data, rather than a string scalar, but I just couldn't seem to write to the
open 'string' file handle?
So I went back to my model outputting the CSV data as a string scalar and
returning it to the controller as it was originally ...
Then rather than directly passing the $xls scalar to response->body, where it
was falling over...
I instead wrap it up into an IO::File object and pass that to the
response->body, and it seem to be working fine!
Here is what I now have in my controller that allows me to parse the CSV scalar
string...
--------------------------------------------------------------------------
my ($result,$xls) = $c->model('NBCSXLSExport')->csv_export;
# check for ok status
if($result->ok)
{
# output header
$c->response->content_type('application/vnd.ms-excel');
$c->response->content_length(length($xls));
$c->response->header(Content_Disposition =>
'attachment;filename=NBCS_Export.csv');
# create an IO::File for Catalyst
use IO::File;
my $iof = IO::File->new;
$iof->open(\$xls, "r");
# output XLS data
$c->response->body($iof);
# close file
undef $iof;
}
else
{
$c->response->body( $result->message );
}
$c->response->status(200);
--------------------------------------------------------
I would like to thank all those who replied with suggestions and especially
Lukas for his help with this final solution.
Regards,
Craig Chant.
-----Original Message-----
From: Craig Chant [mailto:[email protected]]
Sent: 03 May 2013 09:49
To: The elegant MVC web framework
Subject: RE: [Catalyst] Out of Memory - File delivery issue
>Why do you write:
>"I understand that Catalyst has a known issue with delivering authenticated
>files via the response mechanism."
>?
>Have you written a test proving that issue?
Yes, that's why I'm here trying to find a resolve.
Try it yourself, build a large scalar string representing CSV data and pass it
to the response->body() after having output the relevant headers.
The devel server will fall over with 'out of memory' and reboot itself.
I hope to find a solution today with IO::File , but so far no joy!
-----Original Message-----
From: Ferruccio Zamuner [mailto:[email protected]]
Sent: 03 May 2013 09:41
To: [email protected]
Subject: Re: [Catalyst] Out of Memory - File delivery issue
On 05/02/13 09:54, 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?
I've delivered authenticated large files using a Catalyst web app without
trouble using X-Sendfile response header and a front-end webserver like Apache
or Lighttpd.
Why do you write:
"I understand that Catalyst has a known issue with delivering authenticated
files via the response mechanism."
?
Have you written a test proving that issue?
Bye, \ferz
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/
This Email and any attachments contain confidential information and is intended
solely for the individual to whom it is addressed. If this Email has been
misdirected, please notify the author as soon as possible. If you are not the
intended recipient you must not disclose, distribute, copy, print or rely on
any of the information contained, and all copies must be deleted immediately.
Whilst we take reasonable steps to try to identify any software viruses, any
attachments to this e-mail may nevertheless contain viruses, which our
anti-virus software has failed to identify. You should therefore carry out your
own anti-virus checks before opening any documents. HomeLoan Partnership will
not accept any liability for damage caused by computer viruses emanating from
any attachment or other document supplied with this e-mail. HomeLoan
Partnership reserves the right to monitor and archive all e-mail communications
through its network. No representative or employee of HomeLoan Partnership has
the authority to enter into any contract on behalf of HomeLoan Partnership by
email. HomeLoan Partnership is a trading name of H L Partnership Limited,
registered in England and Wales with Registration Number 5011722. Registered
office: 26-34 Old Street, London, EC1V 9QQ. H L Partnership Limited is
authorised and regulated by the Financial Conduct Authority.
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/
This Email and any attachments contain confidential information and is intended
solely for the individual to whom it is addressed. If this Email has been
misdirected, please notify the author as soon as possible. If you are not the
intended recipient you must not disclose, distribute, copy, print or rely on
any of the information contained, and all copies must be deleted immediately.
Whilst we take reasonable steps to try to identify any software viruses, any
attachments to this e-mail may nevertheless contain viruses, which our
anti-virus software has failed to identify. You should therefore carry out your
own anti-virus checks before opening any documents. HomeLoan Partnership will
not accept any liability for damage caused by computer viruses emanating from
any attachment or other document supplied with this e-mail. HomeLoan
Partnership reserves the right to monitor and archive all e-mail communications
through its network. No representative or employee of HomeLoan Partnership has
the authority to enter into any contract on behalf of HomeLoan Partnership by
email. HomeLoan Partnership is a trading name of H L Partnership Limited,
registered in England and Wales with Registration Number 5011722. Registered
office: 26-34 Old Street, London, EC1V 9QQ. H L Partnership Limited is
authorised and regulated by the Financial Conduct Authority.
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/