use strict;
use base 'Class::Accessor::Fast';
-use IO::File;
+use File::Copy ();
+use IO::File ();
__PACKAGE__->mk_accessors(qw/filename size tempname type/);
=head1 SYNOPSIS
+ $upload->copy
$upload->fh
$upload->filename;
$upload->link;
=head1 DESCRIPTION
-This is the Catalyst Request Upload class, which provides a set of accessors to the
-upload data.
+This is the Catalyst Request Upload class, which provides a set of accessors
+to the upload data.
=head1 METHODS
=over 4
+=item $upload->copy( $target [, $bufferlen ] )
+
+Copies tempname using C<File::Copy>. Returns true for success, false otherwise.
+
+=cut
+
+sub copy {
+ my ( $self, $target, $buffer ) = @_;
+ return File::Copy::copy( $self->tempname, $target, $buffer );
+}
+
=item $upload->fh
Opens tempname and returns a C<IO::File> handle.
sub fh {
my $self = shift;
- my $fh = IO::File->new( $self->tempname, O_RDONLY )
+ my $fh = IO::File->new( $self->tempname, IO::File::O_RDONLY )
or die( "Can't open ", $self->tempname, ": ", $! );
return $fh;
=cut
sub link {
- my $self = shift;
- my $target = shift;
-
+ my ( $self, $target ) = @_;
return CORE::link( $self->tempname, $target );
}