From: Andy Grundman Date: Tue, 11 Oct 2005 23:35:03 +0000 (+0000) Subject: Added upload parameters back into req->params X-Git-Tag: 5.7099_04~1222 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=c4bed79ab77673a4b6be73d2e45a27befe91ea3a Added upload parameters back into req->params --- diff --git a/Changes b/Changes index 5b25601..afa85dd 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Tis file documents the revision history for Perl extension Catalyst. 5.50 + - Added upload parameters back into $c->req->params. - Added multiple paths support to dispatcher - Fixed bug in req->path where changing the path added a trailing slash. diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index ba408f9..ecd6834 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -373,6 +373,11 @@ sub prepare_uploads { push @uploads, $u; } $c->request->uploads->{$name} = @uploads > 1 ? \@uploads : $uploads[0]; + + # support access to the filename as a normal param + my @filenames = map { $_->{filename} } @uploads; + $c->request->parameters->{$name} + = @filenames > 1 ? \@filenames : $filenames[0]; } } diff --git a/t/live/engine/request/uploads.t b/t/live/engine/request/uploads.t index fa753c1..7b0f55f 100644 --- a/t/live/engine/request/uploads.t +++ b/t/live/engine/request/uploads.t @@ -6,7 +6,7 @@ use warnings; use FindBin; use lib "$FindBin::Bin/../../lib"; -use Test::More tests => 49; +use Test::More tests => 52; use Catalyst::Test 'TestApp'; use Catalyst::Request; @@ -64,6 +64,9 @@ use HTTP::Request::Common; is( $upload->type, $part->content_type, 'Upload Content-Type' ); is( $upload->size, length( $part->content ), 'Upload Content-Length' ); + # make sure upload is accessible via legacy params->{$file} + is( $creq->{parameters}->{ $upload->filename }, $upload->filename, 'legacy param method ok' ); + ok( ! -e $upload->tempname, 'Upload temp file was deleted' ); } }