RobertCZ wrote:
Stas Bekman wrote:
RobertCZ
wrote:
I'm trying to create temp file in
PerlFixupHandler using File::Temp, write to it, send it to the client
and get the temp file automatically unlinked upon the end of the
request.
I keep getting file permission error.
2) you said:
$fh = new File::Temp( DIR => '/tmp/aimcache', UNLINK => 1 );
so by the time the response phase comes, the file is not there anymore.
instead you could use the approach explained here:
http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlCleanupHandler
or simply use the response phase and sendfile() to send the contents.
This cleanup_register() trick works great, thank
you very much, I have spent way too much time on this thing...
I'm not sure why Gerald Richter uses PerlFixupHandler but I guess he
has his reason, so I don't want to fool with it. (it's
Apache::ImageMagick module I'm trying to port)
I have however one more question (I've posted this in other email, but
it's related): In this FixupHandler when I create a new file and use it
with $r -> filename ($tmpnam) , Apache still thinks size is that of
the originally requested file. Is there a way to change it? Thanks
again.
Geoff just answered, so just for the archives:
well, you message is sufficiently vague since I don't have the
Apache::ImageMagick code handy :)
but I suspect that you mean that the module sets $r->filename and with mp1
the new filename's stat info is updated, but with mp2 it is not? if so,
yes, this is proper - mp1 did magic behind the scenes for you.
with mp2 you need to update the stat info yourself each time you update
$r->filename. something like this:
$r->filename($newfile);
$r->finfo(APR::Finfo::stat($newfile, APR::FINFO_NORM, $r->pool));
|