Advertisement
Guest User

Untitled

a guest
Mar 11th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.05 KB | None | 0 0
  1. sub post_image {
  2.         my $self = shift;
  3.         my $upload = $self->req->upload('file');
  4.  
  5.         # Work out what we're going to call the file
  6.         # Store it in the same place the ftp daemon does
  7.         my $filename = $upload->filename;
  8.         my $original = '/home/ftp/' . $filename;
  9.         $upload->move_to($original);
  10.  
  11.         my $image = Image->new(file => $original); # could load from the file asset file handle...
  12.         my @files = $image->make_thumbnails(); #long slow routine to make 4 thumbnails of the original image.
  13.  
  14.         # Announce to redis if there have been any new files created
  15.         if (@files) {
  16.                 my $r = Redis->new;
  17.                 $r->publish('new_image', $filename);
  18.                 $r->rpush('images', $filename);
  19.         }
  20.  
  21.         my $result_url = $self->url_for('current', id => time()); #totally bogus, will break any *real* gallery3 apps
  22.         $self->render(
  23.                 json => {url => $result_url},
  24.                 format => 'json',
  25.                 status => 201,
  26.         );
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement