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
39 =item $upload->copy_to
41 Copies tempname using C<File::Copy>. Returns true for success, false otherwise.
43 $upload->copy_to('/path/to/target');
49 return File::Copy::copy( $self->tempname, @_ );
54 Opens tempname and returns a C<IO::File> handle.
61 my $fh = IO::File->new( $self->tempname, IO::File::O_RDONLY )
62 or die( "Can't open ", $self->tempname, ": ", $! );
67 =item $upload->filename
69 Contains client supplied filename.
71 =item $upload->link_to
73 Creates a hard link to the tempname. Returns true for success,
76 $upload->link_to('/path/to/target');
81 my ( $self, $target ) = @_;
82 return CORE::link( $self->tempname, $target );
87 Contains size of the file in bytes.
91 Returns a scalar containing contents of tempname.
96 my ( $self, $layer ) = @_;
103 my $handle = $self->fh;
105 binmode( $handle, $layer );
107 while ( $handle->sysread( my $buffer, 8192 ) ) {
114 =item $upload->tempname
116 Contains path to the temporary spool file.
120 Contains client supplied Content-Type.
126 Sebastian Riedel, C<sri@cpan.org>
127 Christian Hansen, C<ch@ngmedia.com>
131 This program is free software, you can redistribute it and/or modify
132 it under the same terms as Perl itself.