minor typos in new Mason.pm
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Request / Upload.pm
index 867c098..43a7cff 100644 (file)
@@ -21,6 +21,7 @@ Catalyst::Request::Upload - Catalyst Request Upload Class
     $upload->filename;
     $upload->link_to;
     $upload->size;
+    $upload->slurp;
     $upload->tempname;
     $upload->type;
 
@@ -44,8 +45,8 @@ Copies tempname using C<File::Copy>. Returns true for success, false otherwise.
 =cut
 
 sub copy_to {
-    my ( $self, $target, $buffer ) = @_;
-    return File::Copy::copy( $self->tempname, $target, $buffer );
+    my $self = shift;
+    return File::Copy::copy( $self->tempname, @_ );
 }
 
 =item $upload->fh
@@ -85,6 +86,31 @@ sub link_to {
 
 Contains size of the file in bytes.
 
+=item $upload->slurp
+
+Returns a scalar containing contents of tempname.
+
+=cut
+
+sub slurp {
+    my ( $self, $layer ) = @_;
+
+    unless ( $layer ) {
+        $layer = ':raw';
+    }
+
+    my $content = undef;
+    my $handle  = $self->fh;
+
+    binmode( $handle, $layer );
+
+    while ( $handle->sysread( my $buffer, 8192 ) ) {
+        $content .= $buffer;
+    }
+
+    return $content;
+}
+
 =item $upload->tempname
 
 Contains path to the temporary spool file.