Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re^4: Catalyst::Request::Upload inside-out-object weirdness

by andye (Curate)
on Mar 26, 2010 at 15:19 UTC ( #831177=note: print w/replies, xml ) Need Help??

in reply to Re^3: Catalyst::Request::Upload inside-out-object weirdness
in thread Catalyst::Request::Upload inside-out-object weirdness

That's right, I don't.

Looking at the source, it looks like that happens in Catalyst::Engine::prepare_uploads

sub prepare_uploads { my ( $self, $c ) = @_; my $request = $c->request; return unless $request->_body; my $uploads = $request->_body->upload; my $parameters = $request->parameters; foreach my $name (keys %$uploads) { my $files = $uploads->{$name}; my @uploads; for my $upload (ref $files eq 'ARRAY' ? @$files : ($files)) { my $headers = HTTP::Headers->new( %{ $upload->{headers} } +); my $u = Catalyst::Request::Upload->new ( size => $upload->{size}, type => $headers->content_type, headers => $headers, tempname => $upload->{tempname}, filename => $upload->{filename}, ); push @uploads, $u; } $request->uploads->{$name} = @uploads > 1 ? \@uploads : $uploa +ds[0]; # support access to the filename as a normal param my @filenames = map { $_->{filename} } @uploads; # append, if there's already params with this name if (exists $parameters->{$name}) { if (ref $parameters->{$name} eq 'ARRAY') { push @{ $parameters->{$name} }, @filenames; } else { $parameters->{$name} = [ $parameters->{$name}, @filena +mes ]; } } else { $parameters->{$name} = @filenames > 1 ? \@filenames : $fil +enames[0]; } } }

Replies are listed 'Best First'.
Re^5: Catalyst::Request::Upload inside-out-object weirdness
by ikegami (Pope) on Mar 26, 2010 at 15:39 UTC

    [The indexing is messed up for this thread. My earlier reply isn't showing, so I'm reposting it]

    Looks like

    can return more than one value. Replace it with
      you're right. amending catalyst::engine to say

      my $u = Catalyst::Request::Upload->new ( size => $upload->{size}, type => $headers->content_type, headers => $headers, tempname => $upload->{tempname}, filename => $upload->{filename}, ); use Data::Dump +er; die '$headers: +'.Dumper($headers). 'type:'.Du +mper($headers->content_type). '$u:'.Dump +er($u). "\nek!";


      [error] Caught exception in engine "$headers:$VAR1 = bless( { 'content-disposition' => 'form-data; name="SourceFile +_1"; filename="aaa.jpg"', 'content-type' => 'image/jpeg; charset=utf-8; Content +-Transfer-Encoding: binary' }, 'HTTP::Headers' ); type:$VAR1 = 'image/jpeg'; $VAR2 = 'charset=utf-8; Content-Transfer-Encoding: binary'; $u:$VAR1 = bless( { 'aaa.jpg' => undef, '/tmp/P3v6fH2JR6' => 'filename', 'HTTP::Headers=HASH(0x40e9e58)' => 'tempname', 'type' => 'image/jpeg', 'charset=utf-8; Content-Transfer-Encoding: binary' => + 'headers', 'size' => 374205 }, 'Catalyst::Request::Upload' ); ek! at /Library/Perl/5.8.6/Catalyst/ line 556."
      so it looks like $headers->content_type is indeed returning two values. I'll suggest a patch.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://831177]
[erix]: ( and when teleology was brought up, during my biology-study., I couldn't get an answer either )
[1nickt]: FTR I agree with you about "design." Just not sure about the trajectory of evolution. THere are a lot of dead-ends in the evolutionary paths. I suspect homo sapiens is just one of them.
[james28909]: thanks for the vid holli, i do like it. thanks for sharing :)
[holli]: gives me goosebumps every time I watch it
holli gotta grab some groceries before dawn. l8ters
[erix]: s/dawn/dusk/
[erix]: (you're welcome :P)
[james28909]: you know, i had a thought a few mnths back. what if this universe were just a puzzle, waiting for life to figure it out!
[james28909]: what if one day we are able to grab the curtain that is "spacetime" and pull it back to reveal <insert imagination here> pulling at levers and ropes xD

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (12)
As of 2017-12-15 14:39 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (433 votes). Check out past polls.