Introduction To Cloudinary's CLI: Overview For Developers and Command Line Interface Users
Introduction To Cloudinary's CLI: Overview For Developers and Command Line Interface Users
Jen Brissman
Technical Curriculum Engineer
Topics
● What is a CLI?
● Setting Up Your Environment
● CLI Helper Tools
● Uploading Assets
● Cloudinary URLs
● Managing Assets
● Sync (Local File Management)
● Transforming Assets
● Next Steps for Further Support
What is a CLI?
Command Line Interface
CLI stands for Command Line Interface
● Text-based interface used for interacting with software and computer systems by
entering commands into a terminal or console.
● In a CLI, users interact with the system by typing commands and receiving
text-based feedback.
● Alternative to Graphical User Interfaces - GUIs, where users interact with software
through graphical elements like windows, icons, and buttons.
Cloudinary CLI
Setting Up Your
Environment
Install Python
To run Cloudinary’s CLI, you need to install
Python, version 3.6 or higher.
$ python3 --version
Important!
Do not expose your API Secret in your client-side code, as it creates a
security risk and potentially allows others to access your account.
API Environment Variable Configuration
Then Export(Mac) or Set (Windows) your CLOUDINARY_URL via the CLI.
export CLOUDINARY_URL=cloudinary://API_KEY:API_SECRET@cloud_name
set CLOUDINARY_URL=cloudinary://API_KEY:API_SECRET@cloud_name
Check Cloudinary Configuration
Check your Cloudinary configuration in the CLI
$ cld config
cloud_name: cloud_name
api_key: API_KEY
api_secret: ***************CRET
private_cdn: False
from_url Configuration
You can also configure from the CLI using cld config --from_url, which will save your configuration
for use beyond a single session.
However, future commands would need to be prefixed with cld -C cloudname, instead of cld.
Options:
--help Show this message and exit.
--version Show the version and exit.
-c, --config TEXT Tell the CLI which account to run the command on by specifying an account environment variable.
-C, --config_saved TEXT Tell the CLI which account to run the command on by specifying a saved configuration
-v, --verbosity LVL Either CRITICAL, ERROR, WARNING, INFO or DEBUG
Commands:
admin Run any methods that can be called through the admin API.
config Display the current configuration, and manage additional...
make Return template code for implementing the specified Cloudinary widget.
migrate Migrate files using an existing auto-upload mapping and a file of URLs.
provisioning Run any methods that can be called through the provisioning API.
regen_derived Regenerate all derived assets pertaining to a named transformation, or transformation string.
search Run the admin API search method.
sync Synchronize between a local directory and a Cloudinary folder.
upload_dir Upload a folder of assets, maintaining the folder structure.
uploader Run any methods that can be called through the upload API.
url Generate a Cloudinary URL, which you can optionally open...
utils Call Cloudinary utility methods.
Basic Commands
To help you get started, here are some basic commands you can use.
$ cld –-version # see versions of Cloudinary CLI, underlying Cloudinary Python SDK and Python
The upload method performs an authenticated upload API call over HTTPS.
● Navigate within the CLI to the local folder that contains the asset you would like to upload.
● Enter the command cld and the name of the asset you would like to upload.
If you don't supply a Public ID in the upload API call, one will be randomly assigned.
https://res.cloudinary.com/demo/image/upload/mountains.jpg
Resource Type
Used to indicate whether you want to upload an image, video or raw file.
You can let Cloudinary determine the type by setting the parameter to “auto”.
https://res.cloudinary.com/demo/video/upload/water-bottle.mp4
Folders
Simply put, folders are a way to organize and divide your files within Cloudinary.
*TIP: A folder will automatically be created for you with this call, if it did not already exist.
{ public_id: mountains-123,
version: '1312461204',
width: 864,
height: 564,
format: 'jpg',
created_at: '2017-08-10T09:55:32Z',
resource_type: 'image',
tags: [],
bytes: 9597,
type: 'upload',
etag: 'd1ac0ee70a9a36b14887aca7f7211737',
url: 'http://res.cloudinary.com/demo/image/upload/v1312461204/sample.jpg',
secure_url: 'https://res.cloudinary.com/demo/image/upload/v1312461204/sample.jpg',
signature: 'abcdefgc024acceb1c1baa8dca46717137fa5ae0c3',
original_filename: 'sample'}
Upload Widget
You can implement Cloudinary’s
Upload Widget to easily upload assets
from the frontend of a web/mobile
browser directly to your Cloudinary
account, without involving any servers
in the process.
Resource Type
<resource_type>/ https://res.cloudinary.com/jen-brissman/image/upload/v1702185884/mountains.jpg
<domain>/<cloud_name>/<resource_type>/<type>/<version>/<public_id>.<format>
Delivery Type <type>/
Transformations
<transformations>/
Version <version>/
The utils command enables you to call Cloudinary utility methods. One of these is the
cloudinary_url method, for embedding images in web pages using SDKs.
https://res.cloudinary.com/demo/image/upload/c_scale,w_300/mountains
Managing Assets
Upload API Admin API
Managing Assets
● List Resources
● Search
● Rename
● Tags
● Delete
● Invalidate and Versioning
List Resources
Using Admin API methods with the Cloudinary CLI, you can list all of your uploaded
assets by many different sets of criteria.
● Lucene-like query
You can also use our AI auto tagging add-ons to further automate the tagging process
You can use the delete_resources method of the Admin API delete multiple assets at one
time by their Public ID or even a prefix in the Public ID with our Admin API.
Note: From within the UI/DAM, an invalidate request is automatically included whenever you
delete, rename, or overwrite media assets.
To check versioning:
Similar to git syntax, sync allows you to push to the cloud and pull from the cloud.
Keep in mind that in this case sync does not mean constantly syncing or “synchronizing”.
If you want to download the “test-assets” folder from Cloudinary to another local directory,
for example “~/Desktop/pulled-from-cld”, you can use the pull option.
http://res.cloudinary.com/jen-brissman/image/upload/w_300/hiker
Format (f_auto)
Use Cloudinary to automatically convert
assets to other formats for displaying in your
web site or application (output formats).
http://res.cloudinary.com/jen-brissman/image/upload/f_auto/hiker
Crop with Gravity
You can use Gravity to specify a location
in an image or video that is used as the
focus for another transformation.
https://res.cloudinary.com/jen-brissman/image/upload/w_500,h_500,c_thumb,g_auto/hiker
Rounding for Aesthetics
For rounding, you can use the radius parameter to
control the degree of rounding applied to the image.
https://res.cloudinary.com/jen-brissman/image/upload/w_500,h_500,c_thumb,g_auto,r_max,e_grayscale,f_auto/hiker
Quality (q_auto)
Quality controls the visual quality and
compression level of assets.
training.cloudinary.com
Recommended Courses
Those who are new to Cloudinary's APIs can benefit from
a variety of helpful, self-paced courses that provide
comprehensive learning resources.
github.com/cloudinary-training
github.com/cloudinary
Engineering Support
We are always happy to answer your questions, as we have dedicated support
staff for our developer community.
support.cloudinary.com/hc/en-us/requests/new
Join Our Community Forums
Ask questions to staff or other users in our dedicated communities.
community.cloudinary.com
Join Our Discord Discussions
Connect with Cloudinary users and staff on Discord!
discord.gg/cloudinary
Thank you