X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FRequest%2FUpload.pm;h=486653c61b582d7c265429a5218da04a0d85f64d;hp=6df2dffca7e675ef815763e6434d58e6120b761f;hb=2d48c2fc524aa2c1c077ba4be61970ed698af12d;hpb=6adc45cf93c50a080f1f32bad475fd2ab5844887 diff --git a/lib/Catalyst/Request/Upload.pm b/lib/Catalyst/Request/Upload.pm index 6df2dff..486653c 100644 --- a/lib/Catalyst/Request/Upload.pm +++ b/lib/Catalyst/Request/Upload.pm @@ -99,6 +99,14 @@ false for failure. $upload->copy_to('/path/to/target'); +Please note the filename used for the copy target is the 'tempname' that +is the actual filename on the filesystem, NOT the 'filename' that was +part of the upload headers. This might seem counter intuitive but at this +point this behavior is so established that its not something we can change. + +You can always create your own copy routine that munges the target path +as you wish. + =cut sub copy_to { @@ -135,8 +143,8 @@ is found. This also accepts an override encoding value that you can use to force a particular L layer. If neither are found the filehandle is set to :raw. -This is useful if you are pulling the file into code and inspecting bit and -maybe then sending those bits back as the response. (Please not this is not +This is useful if you are pulling the file into code and inspecting bits and +maybe then sending those bits back as the response. (Please note this is not a suitable filehandle to set in the body; use C if you are doing that). Please note that using this method sets the underlying filehandle IO layer @@ -203,14 +211,20 @@ sub slurp { $layer = ':raw'; } - my $content = undef; + my $content = ''; my $handle = $self->fh; binmode( $handle, $layer ); $handle->seek(0, IO::File::SEEK_SET); - while ( $handle->sysread( my $buffer, 8192 ) ) { - $content .= $buffer; + + if ($layer eq ':raw') { + while ( $handle->sysread( my $buffer, 8192 ) ) { + $content .= $buffer; + } + } + else { + $content = do { local $/; $handle->getline }; } $handle->seek(0, IO::File::SEEK_SET); @@ -229,11 +243,9 @@ sub decoded_slurp { my ( $self, $layer ) = @_; my $handle = $self->decoded_fh($layer); - my $content = undef; $handle->seek(0, IO::File::SEEK_SET); - while ( $handle->sysread( my $buffer, 8192 ) ) { - $content .= $buffer; - } + + my $content = do { local $/; $handle->getline }; $handle->seek(0, IO::File::SEEK_SET); return $content;