1 package Catalyst::Request::Upload;
4 use base 'Class::Accessor::Fast';
9 __PACKAGE__->mk_accessors(qw/filename size tempname type/);
11 sub new { shift->SUPER::new( ref( $_[0] ) ? $_[0] : {@_} ) }
15 Catalyst::Request::Upload - Catalyst Request Upload Class
32 This is the Catalyst Request Upload class, which provides a set of accessors
43 =item $upload->copy_to
45 Copies tempname using C<File::Copy>. Returns true for success, false otherwise.
47 $upload->copy_to('/path/to/target');
53 return File::Copy::copy( $self->tempname, @_ );
58 Opens tempname and returns a C<IO::File> handle.
65 my $fh = IO::File->new( $self->tempname, IO::File::O_RDONLY )
66 or die( "Can't open ", $self->tempname, ": ", $! );
71 =item $upload->filename
73 Contains client supplied filename.
75 =item $upload->link_to
77 Creates a hard link to the tempname. Returns true for success,
80 $upload->link_to('/path/to/target');
85 my ( $self, $target ) = @_;
86 return CORE::link( $self->tempname, $target );
91 Contains size of the file in bytes.
95 Returns a scalar containing contents of tempname.
100 my ( $self, $layer ) = @_;
107 my $handle = $self->fh;
109 binmode( $handle, $layer );
111 while ( $handle->sysread( my $buffer, 8192 ) ) {
118 =item $upload->tempname
120 Contains path to the temporary spool file.
124 Contains client supplied Content-Type.
130 Sebastian Riedel, C<sri@cpan.org>
131 Christian Hansen, C<ch@ngmedia.com>
135 This program is free software, you can redistribute it and/or modify
136 it under the same terms as Perl itself.