From: Marcus Ramberg Date: Thu, 30 Mar 2006 12:29:34 +0000 (+0000) Subject: applied patch to allow a tmpdir setting. X-Git-Tag: 5.7099_04~655 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=7257e9dbc2d2550e43b0ddeb1027360428a3c44f;hp=73664287069fe2e0c731df29f80b5c19838c60d2 applied patch to allow a tmpdir setting. --- diff --git a/Changes b/Changes index b388fa8..f5cdebb 100644 --- a/Changes +++ b/Changes @@ -8,6 +8,8 @@ This file documents the revision history for Perl extension Catalyst. - Changed default behaviors for $c->model/$c->controller/$c->view to more sane settings. - added the clear_errors method - an alias for error(0) + - Added tmpdir option for uploads (Kei OHSHIRO) + - Applied patch from GEOFFR to allow normal filehandles. 5.66 2006-03-10 17:48:00 - Added Test::WWW::Mechanize::Catalyst support diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index ff2e797..0c8929a 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -39,15 +39,16 @@ Finalize body. Prints the response output. sub finalize_body { my ( $self, $c ) = @_; - if ( ref $c->response->body && $c->response->body->can('read') ) { - while ( !$c->response->body->eof() ) { - $c->response->body->read( my $buffer, $CHUNKSIZE ); + my $body = $c->response->body; + if ( ref $body && ($body->can('read') || ref($body) eq 'GLOB') ) { + while ( !eof $body ) { + read $body, my $buffer, $CHUNKSIZE; last unless $self->write( $c, $buffer ); } - $c->response->body->close(); + close $body; } else { - $self->write( $c, $c->response->body ); + $self->write( $c, $body ); } } @@ -315,6 +316,7 @@ sub prepare_body { unless ( $c->request->{_body} ) { $c->request->{_body} = HTTP::Body->new( $type, $self->read_length ); + $c->request->{_body}->{tmpdir} = $c->config->{uploadtmp} if exists $c->config->{uploadtmp}; } if ( $self->read_length > 0 ) { diff --git a/lib/Catalyst/Request/Upload.pm b/lib/Catalyst/Request/Upload.pm index 9a5f1c4..a3e6f55 100644 --- a/lib/Catalyst/Request/Upload.pm +++ b/lib/Catalyst/Request/Upload.pm @@ -27,6 +27,11 @@ Catalyst::Request::Upload - handles file upload requests $upload->tempname; $upload->type; +To specify where Catalyst should put the temporary files, set the 'uploadtmp' +option in the Catalyst config. If unset, Catalyst will use the system temp dir. + + __PACKAGE__->config( uploadtmp => '/path/to/tmpdir' ); + See also L. =head1 DESCRIPTION