[Catalyst] Out of Memory - File delivery issue

Lukas Thiemeier spamcatcher at thiemeier.net
Thu May 2 09:33:19 GMT 2013


On 05/02/2013 09:54 AM, 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?
> 

Hi Craig,

I never had problems delivering large files, but I don't know what you
consider "large".

About delivering large static files: I would recommend to use the web
server to serve static files, no matter if they are large or not. You
can set up authentication in your web server and use
Catalyst::Authentication::Credential::Remote to use the webservers
authentication in your Catalyst app.

Another possibility is to use Static::Simple to deliver static files. I
successfully delivered files > 4gb using Static::Simple. Is this large
enough for you?

AFAIK, Static::Simple has no build in support for authentication, but
you could add a "around" modifier in YourApp.pm and do the
authentication stuff before calling $c->$orig. You will have to take a
look at the code in Static::Simple to find out what method to modify. I
am aware that this is NOT a optimal solution. In fact, I think that this
approach is very hacky and dirty. But without trying it: I am (almost)
sure that it will work.

The topic "creating large XML Files" has come up on this mailing list
before. This thread might be helpful:

http://www.gossamer-threads.com/lists/catalyst/users/30931

If you are trying to create a XML File in Memory which is larger than
your memory, you do have a problem. But that is not Catalyst specific at
all. Try writing the XML Data to your hard disk, and deliver the
resulting file.

I guess someone with more knowledge about the Cat internals or more
experience with processing large files can give you a better advice. But
I still hope this info is useful.

Cheers, Lukas



More information about the Catalyst mailing list