Cloudinary

 view release on metacpan or  search on metacpan

Cloudinary-0.16/Cloudinary-0.16/lib/Cloudinary.pm  view on Meta::CPAN

package Cloudinary;
use Mojo::Base -base;
use File::Basename;
use Mojo::UserAgent;
use Mojo::Util qw(sha1_sum url_escape);
use Scalar::Util 'weaken';

our $VERSION = '0.16';
our (%SHORTER, %LONGER);
my @SIGNATURE_KEYS = qw(callback eager format public_id tags timestamp transformation type);

{
  %LONGER = (
    a => 'angle',
    b => 'background',
    c => 'crop',

Cloudinary-0.16/Cloudinary-0.16/lib/Cloudinary.pm  view on Meta::CPAN

}

sub _call_api {
  my ($self, $action, $args, $post, $cb) = @_;
  my $url = join '/', $self->_api_url, $self->cloud_name, $args->{resource_type}, $action;
  my $headers = {'Content-Type' => 'multipart/form-data'};

  $post->{api_key}   = $self->api_key;
  $post->{signature} = $self->_api_sign_request($post);

  Scalar::Util::weaken($self);
  my $tx = $self->_ua->post(
    $url, $headers,
    form => $post,
    $cb ? sub { $self->$cb($_[1]->res->json || {error => $_[1]->error || 'Unknown error'}) } : (),
  );

  return $self if $cb;    # non-blocking
  my $res = $tx->error;
  die $res->{message} || 'Unknown error' if $res;
  $res = $tx->res->json;

lib/Cloudinary.pm  view on Meta::CPAN

package Cloudinary;
use Mojo::Base -base;
use File::Basename;
use Mojo::UserAgent;
use Mojo::Util qw(sha1_sum url_escape);
use Scalar::Util 'weaken';

our $VERSION = '0.16';
our (%SHORTER, %LONGER);
my @SIGNATURE_KEYS = qw(callback eager format public_id tags timestamp transformation type);

{
  %LONGER = (
    a => 'angle',
    b => 'background',
    c => 'crop',

lib/Cloudinary.pm  view on Meta::CPAN

}

sub _call_api {
  my ($self, $action, $args, $post, $cb) = @_;
  my $url = join '/', $self->_api_url, $self->cloud_name, $args->{resource_type}, $action;
  my $headers = {'Content-Type' => 'multipart/form-data'};

  $post->{api_key}   = $self->api_key;
  $post->{signature} = $self->_api_sign_request($post);

  Scalar::Util::weaken($self);
  my $tx = $self->_ua->post(
    $url, $headers,
    form => $post,
    $cb ? sub { $self->$cb($_[1]->res->json || {error => $_[1]->error || 'Unknown error'}) } : (),
  );

  return $self if $cb;    # non-blocking
  my $res = $tx->error;
  die $res->{message} || 'Unknown error' if $res;
  $res = $tx->res->json;

lib/Mojolicious/Plugin/Cloudinary.pm  view on Meta::CPAN

package Mojolicious::Plugin::Cloudinary;
use Mojo::Base -base;
use File::Basename;
use Mojo::UserAgent;
use Mojo::Util qw(sha1_sum url_escape);
use Scalar::Util 'weaken';
use base qw(Cloudinary Mojolicious::Plugin);

our $VERSION = 0.0402;    # just need something higher than the previous version

has js_image => '/image/blank.png';

sub register {
  my ($self, $app, $config) = @_;

  for my $k (keys %{$config || {}}) {



( run in 0.304 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )