Install the CLI tool and the library with:
go get github.com/rootsongjc/cloudinary-go/cloudinary
Or download the release binary from release.
Create a default configuration file named
[cloudinary] uri=cloudinary://api_key:[email protected]_name # check your cloudinary dashboard to the the uri prepend = "images" # default cloudinary folder
A CLI tool to upload static assets to the Cloudinary service. Usage: cloudinary [command] Available Commands: help Help about any command ls List files put Upload file rm Remove file Flags: --config string config file (default is $HOME/.cloudinary.toml) -h, --help help for cloudinary -i, --image string image filename or public id -p, --path string flle prepend path -r, --raw string raw filename or public id -s, --simulate simulate, do nothing (dry run) -v, --verbose verbose output Use "cloudinary [command] --help" for more information about a command.
cloudinary in the terminal to get some help.
# upload image file cloudinary put -i abc.jpg -p images # upload raw file cloudinary put -r abc.js -p js
As the local image uploaded to cloudinary, you will get a URL such like this:
cloudinary put -i cover.jpg Using config file: /Users/jimmy/.cloudinary.toml Warning: database not set (upload sync disabled) Default remote prepend path set to: images/ ==> PublicID: images/cover ==> Uploading as images 2017/10/29 14:49:01 Uploading: cover.jpg 2017/10/29 14:49:06 URL: https://res.cloudinary.com/jimmysong/image/upload/images/cover.jpg
https://res.cloudinary.com/jimmysong/image/upload/images/cover.jpg represent the laster version of the image.
You can use
ls to get the upload version.
# list all resources cloudinary ls # list specified static file details cloudinary ls -i abc -p images
List raw file details not support.
Get the upload version.
cloudinary ls -i cover.jpg Using config file: /Users/jimmy/.cloudinary.toml Warning: database not set (upload sync disabled) Default remote prepend path set to: images/ ==> PublicID: images/cover ==> Image Details: public_id Format Version Type Size(KB) Width Height Url images/cover jpg 1509259745 image 297 1800 2360 http://res.cloudinary.com/jimmysong/image/upload/v1509259745/images/cover.jpg
Note: Whether You can specify the file name with extension name or not, that also works.
# delete image cloudinary delete -i abc -p images # delete raw resource cloudinary delete -r abc.js -p js
- Cloudinary prepend path should not start with a “/” root path
- PublicID of Image resource doesn’t include their extension name
- PublicID of Raw resource include their extension name
- PublicID includes the prepend path
|Local file||Prepend path||PublicID|
More information see Cloudinary Image upload API reference