From: Chris W. <ch...@cw...> - 2004-04-28 01:28:19
|
On Apr 26, 2004, at 1:01 PM, Teemu Arina wrote: ... > I have a system that generates a temporary file with a filehandle and > when the > temporary filehandle object goes out of scope, the temporary file is > destroyed. This was a problem if I wanted to send the contents of the > file to > the client. I had two options: > 1. > Modifying $R->{page}{content_type} and returning the file contents > from the OI > Handler. This is a problem, I don't want to load an entire file in the > memory. > > 2. > Modifying $R->{page}{content_type} and using $R->{page}{send_file} for > returning contents of a file. This only allows the filename and since > I'm > using a temporary filehandle object that goes out of scope, I had to > modify > OpenInteract.pm to allow returning filehandles instead of filenames. Yes, the second one is definitely better and is a good idea. I'm committing a version of it to CVS. However, there's one thing we may need to change: If you specify a filehandle in $R->{page}{send_file} you must specify in '$R->{page}{content_type}' otherwise we won't know what to send the client, and some clients don't like that... I've implemented it with a default MIME type of unspecified ('application/octet-stream'). > Is there a better method? I think OpenInteract was not scalable enough > in this > kind of fundamental issue. Is this different in OI2? Well, AFAIK it hasn't come up before -- most of the time you don't have this temporary file restriction. That said, I can just added 'send_filehandle' to OI2::Response as a companion property to 'send_file'. (You'll still need to set the content type...) Chris -- Chris Winters Creating enterprise-capable snack systems since 1988 |