Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my $delay = Mojo::IOLoop->delay(sub{
- my $delay = shift;
- my @all = @_;
- my @ress = map {$all[$_]} grep {!($_ & 1)} 0..$#all; # gets rid of all odd elements
- my $atleastonefailure = 0;
- foreach my $res (@ress){
- if(!$res){ # at least one upload failed
- $atleastonefailure++;
- }
- else{
- my $found = 0;
- foreach my $o (keys %{$sessimghash}){
- if($sessimghash->{$o}->{cloudid} eq $res->{public_id}){
- $sessimghash->{$o}->{cloudyflag} = 1;
- $found = 1;
- last;
- }
- }
- return $self->render('minhaloja', regstatus => 'errcloudses') if(!$found);
- }
- }
- if($atleastonefailure){
- return $self->render('minhaloja', regstatus => 'errcloudfail');
- }
- # all submitted images uploaded ok and form parameters validated
- return $self->render('minhaloja', regstatus => 'ok');
- });
- foreach my $picio (1..scalar(@pics2upload)){
- my $md5 = datamd5($pics2upload[$picio-1]->slurp);
- my $pubid = $self->uuid;
- $self->pictures($picio => {md5 => $md5, cloudid => $pubid, cloudyflag => 0});
- $self->cloudinary_upload({
- file => $pics2upload[$picio-1],
- public_id => $pubid, # that's how we will recognize that image upload in on_finish()
- delay => $delay->begin,
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement