X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FRequest%2FUpload.pm;h=1427bcb1852198e658e4911e6ea22e35a6dffde5;hb=554c758740d1f5b5b548b777e7180e556f9f6a55;hp=aee362568e5cac7adb5f8db897e4c96ed5b9da0a;hpb=b0ad47c12a21862b08d8e2942095065ac2f7edf2;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Request/Upload.pm b/lib/Catalyst/Request/Upload.pm index aee3625..1427bcb 100644 --- a/lib/Catalyst/Request/Upload.pm +++ b/lib/Catalyst/Request/Upload.pm @@ -5,8 +5,9 @@ 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; +use namespace::clean -except => 'meta'; has filename => (is => 'rw'); has headers => (is => 'rw'); @@ -128,6 +129,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 +147,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; }