Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jhthorsen/cloudinary
Talk with cloudinary.com using Perl
https://github.com/jhthorsen/cloudinary
Last synced: 27 days ago
JSON representation
Talk with cloudinary.com using Perl
- Host: GitHub
- URL: https://github.com/jhthorsen/cloudinary
- Owner: jhthorsen
- Created: 2012-05-20T14:06:52.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-12-25T09:33:33.000Z (about 7 years ago)
- Last Synced: 2024-10-16T11:58:29.988Z (3 months ago)
- Language: Perl
- Size: 67.4 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
Awesome Lists containing this project
README
NAME
Cloudinary - Talk with cloudinary.comVERSION
0.15DESCRIPTION
This module lets you interface to .SYNOPSIS
Standalone
my $delay = Mojo::IOLoop->delay;
my $cloudinary = Cloudinary->new(cloud_name => "a", api_key => "b", api_secret => "c");$delay->begin;
$cloudinary->upload({file => {file => $path_to_file}}, sub {
my ($cloudinary, $res) = @_;
# ...
$delay->end;
},
});# let's you do multiple upload() in parallel
# just call $delay->begin once pr upload()
# and $delay->end in each callback given to upload()
$delay->wait;With mojolicious
See Mojolicious::Plugin::Cloudinary.Options
As from 0.04 all methods support the short and long option, meaning the
examples below work the same:$self->url_for('billclinton.jpg' => { w => 50 });
$self->url_for('billclinton.jpg' => { width => 50 });url_for() examples
$cloudinary->url_for('billclinton.jpg', { type => 'facebook' });
$cloudinary->url_for('billclinton.jpg', { type => 'twitter_name', h => 70, w => 100 });
$cloudinary->url_for('18913373.jpg', { type => 'twitter_name' });
$cloudinary->url_for('my-uploaded-image.jpg', { h => 50, w => 50 });
$cloudinary->url_for('myrawid', { resource_type => 'raw' });Aliases
This module provides alias for the Cloudinary transformations:a = angle
b = background
c = crop
d = default_image
e = effect
f = fetch_format
g = gravity
h = height
l = overlay
p = prefix
q = quality
r = radius
t = named_transformation
w = width
x = x
y = yATTRIBUTES
cloud_name
Your cloud name fromapi_key
Your API key fromapi_secret
Your API secret fromprivate_cdn
Your private CDN url from .METHODS
upload
$self->upload(
{
file => $binary_str | $url, # required
format => $str, # optional
public_id => $str, # optional
resource_type => $str, # image or raw. defaults to "image"
tags => ['foo', 'bar'], # optional
timestamp => $epoch, # time()
},
sub { my ($cloudinary, $res) = @_ }
);Will upload a file to using the parameters given
"cloud_name", "api_key" and "api_secret". $res in the callback will be
the json response from cloudinary:{
url => $str,
secure_url => $str,
public_id => $str,
version => $str,
width => $int, # only for images
height => $int, # only for images
}$res on error can be either "undef" if there was an issue
connecting/communicating with cloudinary or a an error data structure:{error => {message: $str}}
The "file" can be:
* A hash
{ file => 'path/to/image' }
* A Mojo::Upload object.
* A Mojo::Asset object.
* A URL
"res" in callbacks will be the JSON response from
as a hash ref. It may also be "undef" if
something went wrong with the actual HTTP POST.See also and
.destroy
$self->destroy(
{
public_id => $public_id,
resource_type => $str, # image or raw. defaults to "image"
},
sub { my ($cloudinary, $res) = @_; }
);Will delete an image from cloudinary, identified by $public_id. The
callback will be called when the image got deleted or if an error occur.On error, look for:
{error => {message: $str}}
See also
.url_for
$url_obj = $self->url_for("$public_id.$format", \%args);This method will return a public URL to the image at
. It will use "private_cdn" or the public CDN and
"cloud_name" to construct the URL. The return value is a Mojo::URL
object.Example %args:
{
h => 150, # height of image
w => 100, # width of image
resource_type => $str, # image or raw. defaults to "image"
secure => $bool, # use private_cdn or public cdn
type => $str, # upload, facebook. defaults to "upload"
}See also
and .COPYRIGHT & LICENSE
This library is free software. You can redistribute it and/or modify it
under the same terms as Perl itself.AUTHOR
Jan Henning Thorsen - [email protected]