cloudinate
Batch upload files to Cloudinary
Cloudinate automates uploading files to Cloudinary. It accepts a glob pattern and uploads all files that match the pattern to Cloudinary. Cloudinate is meant to simplify the uploading of assets for the metalsmith-cloudinary plugin, but can of course be used for other purposes as well.
Installation
$ npm install cloudinate
Cloudinate can also be installed globally with npm install cloudinate -g
Usage
local install
If you've installed cloudinate locally you could use a script upload.js
:
var cloudinate = require('cloudinate');
var keys = require('./keys')
cloudinate({
keys: keys,
files: './images/*.jpg'
});
Where keys.js
is a module that exports your api keys like so:
module.exports = {
'cloud_name': 'your_cloud_name_here',
'api_key': 'your_api_key_here',
'api_secret': 'your_api_secret_here'
}
Run the above script with node upload.js
.
global install
Or if you've installed cloudinate globally, you can run it from the command line like so:
$ cloudinate -k 'keys.js' -f 'images/**/*.jpg'
Options
You can pass the following options:
- files: a glob pattern of the files to upload (required, command line flag:
-f
) - keys: an object containing your Cloudinary
cloud_name
, api_key
and api_secret
(required, command line flag: -k
) - relativeTo: a path, public_ids will be generated relative to this path (optional, command line flag:
-r
)
What does it do
Cloudinate will upload the files that match the supplied pattern. Uploaded files will be given a public_id
according to their relative path and name, to make subsequent retrieval easier.
For example, successfully uploading images/1.jpg
would result in output that resembles:
{
public_id: 'images/1',
version: {version number here},
signature: {signature number here},
width: 7200,
height: 10800,
format: 'jpg',
resource_type: 'image',
created_at: '2016-02-20T12:44:44Z',
tags: [],
bytes: 3008861,
type: 'upload',
etag: {etag number here},
url: 'http://res.cloudinary.com/{cloud_name_here}/image/upload/v{version_number_here}/images/1.jpg',
secure_url: 'https://res.cloudinary.com/{cloud_name_here}/image/upload/v{version_number_here}/images/1.jpg',
original_filename: '1'
}
License
MIT