sub finalize_body {
my ( $self, $c ) = @_;
my $body = $c->response->body;
- if ( ref $body && ( $body->can('read') || ref($body) eq 'GLOB' ) ) {
+ no warnings 'uninitialized';
+ if ( Scalar::Util::blessed($body) && $body->can('read') or ref($body) eq 'GLOB' ) {
while ( !eof $body ) {
read $body, my ($buffer), $CHUNKSIZE;
last unless $self->write( $c, $buffer );
# support access to the filename as a normal param
my @filenames = map { $_->{filename} } @uploads;
- $c->request->parameters->{$name} =
- @filenames > 1 ? \@filenames : $filenames[0];
+ # append, if there's already params with this name
+ if (exists $c->request->parameters->{$name}) {
+ if (ref $c->request->parameters->{$name} eq 'ARRAY') {
+ push @{ $c->request->parameters->{$name} }, @filenames;
+ }
+ else {
+ $c->request->parameters->{$name} =
+ [ $c->request->parameters->{$name}, @filenames ];
+ }
+ }
+ else {
+ $c->request->parameters->{$name} =
+ @filenames > 1 ? \@filenames : $filenames[0];
+ }
}
}