1 package Catalyst::Request::Upload;
4 use base 'Class::Accessor::Fast';
9 __PACKAGE__->mk_accessors(qw/filename size tempname type/);
14 Catalyst::Request::Upload - Catalyst Request Upload Class
31 This is the Catalyst Request Upload class, which provides a set of accessors
40 Constructor. Normally only for engine use.
44 sub new { shift->SUPER::new( ref( $_[0] ) ? $_[0] : {@_} ) }
46 =item $upload->copy_to
48 Copies tempname using C<File::Copy>. Returns true for success, false otherwise.
50 $upload->copy_to('/path/to/target');
56 return File::Copy::copy( $self->tempname, @_ );
61 Opens tempname and returns a C<IO::File> handle.
68 my $fh = IO::File->new( $self->tempname, IO::File::O_RDONLY )
69 or die( "Can't open ", $self->tempname, ": ", $! );
74 =item $upload->filename
76 Contains client supplied filename.
78 =item $upload->link_to
80 Creates a hard link to the tempname. Returns true for success,
83 $upload->link_to('/path/to/target');
88 my ( $self, $target ) = @_;
89 return CORE::link( $self->tempname, $target );
94 Contains size of the file in bytes.
98 Returns a scalar containing contents of tempname.
103 my ( $self, $layer ) = @_;
110 my $handle = $self->fh;
112 binmode( $handle, $layer );
114 while ( $handle->sysread( my $buffer, 8192 ) ) {
121 =item $upload->tempname
123 Contains path to the temporary spool file.
127 Contains client supplied Content-Type.
133 Sebastian Riedel, C<sri@cpan.org>
134 Christian Hansen, C<ch@ngmedia.com>
138 This program is free software, you can redistribute it and/or modify
139 it under the same terms as Perl itself.