Cloudinary
view release on metacpan or search on metacpan
Cloudinary-0.16/Cloudinary-0.16/lib/Cloudinary.pm view on Meta::CPAN
12345678910111213141516package
Cloudinary;
use
Mojo::Base -base;
use
File::Basename;
use
Mojo::UserAgent;
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
107108109110111112113114115116117118119120121122123124125126127}
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
12345678910111213141516package
Cloudinary;
use
Mojo::Base -base;
use
File::Basename;
use
Mojo::UserAgent;
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
107108109110111112113114115116117118119120121122123124125126127}
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
12345678910111213141516package
Mojolicious::Plugin::Cloudinary;
use
Mojo::Base -base;
use
File::Basename;
use
Mojo::UserAgent;
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.348 second using v1.01-cache-2.11-cpan-4e96b696675 )