X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FRequest%2FUpload.pm;h=167553136c499604053b84dd324baeb666187692;hb=0fd00e7bbc4486802b14242c4fcc53214db7818d;hp=ed3b0f595b9eb9803ded389f3314ac00cf2c0c28;hpb=33455c7efee402cf37036546c14625a3df20a0fd;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Request/Upload.pm b/lib/Catalyst/Request/Upload.pm index ed3b0f5..1675531 100644 --- a/lib/Catalyst/Request/Upload.pm +++ b/lib/Catalyst/Request/Upload.pm @@ -5,7 +5,7 @@ with 'MooseX::Emulate::Class::Accessor::Fast'; use Catalyst::Exception; use File::Copy (); -use IO::File (); +use IO::File qw( SEEK_SET ); use File::Spec::Unix; has filename => (is => 'rw'); @@ -108,7 +108,7 @@ Returns an L object for the request. =head2 $upload->link_to -Creates a hard link to the temporary file. Returns true for success, +Creates a hard link to the temporary file. Returns true for success, false for failure. $upload->link_to('/path/to/target'); @@ -128,6 +128,10 @@ Returns the size of the uploaded file in bytes. Returns a scalar containing the contents of the temporary file. +Note that this method will cause the filehandle pointed to by +C<< $upload->fh >> to be seeked to the start of the file, +and the file handle to be put into binary mode. + =cut sub slurp { @@ -142,10 +146,12 @@ sub slurp { binmode( $handle, $layer ); + $handle->seek(0, SEEK_SET); while ( $handle->sysread( my $buffer, 8192 ) ) { $content .= $buffer; } + $handle->seek(0, SEEK_SET); return $content; } @@ -171,7 +177,7 @@ Catalyst Contributors, see Catalyst.pm =head1 COPYRIGHT -This program is free software, you can redistribute it and/or modify +This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself. =cut