| HTML-FormFu documentation | Contained in the HTML-FormFu distribution. |
HTML::FormFu::QueryType::Catalyst
If you use Catalyst::Controller::HTML::FormFu, it will automatically set
query_type in HTML::FormFu to Catalyst.
We no longer keep a reference to the Catalyst::Request::Upload object, as it was causing issues under HTML::FormFu::MultiForm after the Catalyst 5.8 move to Moose.
Because catalyst_upload has been removed, we can no-longer call this Catalyst::Request::Upload method.
Because catalyst_upload has been removed, we can no-longer call this Catalyst::Request::Upload method.
Is a sub-class of, and inherits methods from HTML::FormFu::Upload
Carl Franks, cfranks@cpan.org
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
| HTML-FormFu documentation | Contained in the HTML-FormFu distribution. |
package HTML::FormFu::QueryType::Catalyst; use Moose; extends 'HTML::FormFu::Upload'; use IO::File (); use Scalar::Util qw( weaken ); has basename => ( is => 'rw', traits => ['Chained'] ); has tempname => ( is => 'rw', traits => ['Chained'] ); sub parse_uploads { my ( $class, $form, $name ) = @_; my @params = $form->query->param($name); my @uploads = $form->query->upload($name); my @new; # if all params aren't files, # the files will be at the end of @params my $non_file_count = scalar @params - scalar @uploads; if ( $non_file_count > 0 ) { splice @params, $non_file_count; push @new, @params; } for my $upload (@uploads) { my $param = $class->new( { parent => $form, basename => $upload->basename, headers => $upload->headers, filename => $upload->filename, tempname => $upload->tempname, size => $upload->size, type => $upload->type } ); push @new, $param; } return if !@new; return @new == 1 ? $new[0] : \@new; } # copied from Catalyst 5.7x series - before it was Moosified sub fh { my $self = shift; my $fh = IO::File->new( $self->tempname, IO::File::O_RDONLY ); unless ( defined $fh ) { my $filename = $self->tempname; Catalyst::Exception->throw( message => qq/Can't open '$filename': '$!'/ ); } return $fh; } __PACKAGE__->meta->make_immutable; 1; __END__