In this module we walk through how to programmatically create two different upload presets and then use those presets to upload assets to Cloudinary. We also take a peek at a more complex preset that you could use to process short form video.
You will need to install Node.js on your machine, version 10 or higher. Installing Node.js will also install npm, the package manager for Node.js.
Using Homebrew:
brew install node
$ node --version
v16.13.0
$ npm --version
8.1.0
Visual Studio Code WebStorm Sublime Atom iTerm
cust-training-2022 GitHub Repository
- Assets are located in
/assets
directory - Run code from root directory
-
Create a free account on Cloudinary at [https://www.cloudinary.com/signup]
-
Navigate to the Dashboard. Copy the
CLOUDINARY_URL
into your clipboard.
- Key: CLOUDINARY_URL
- Value: cloudinary://API_KEY:API_SECRET@CLOUD_NAME
- Create a
.env
file in the root of the project. Paste the CLOUDINARY_URL environment variable into your.env
file.
Npm install Node.js libraries. You will be using the cloudinary
and the dotenv
libraries.
npm i
Example: run image upload script
node optimization/images/upload.js
You can find a video tutorial: in Cloudinary Documentation that covers Node.js setup and upload to your Cloudinary cloud.
Additional information about upload presets from the docs upload presets docs:
Photo by Andrea Piacquadio from Pexels: https://www.pexels.com/photo/woman-in-collared-shirt-774909/
Photo by Ganimat Pashazade from Pexels: https://www.pexels.com/photo/baby-in-white-and-blue-jacket-lying-on-snow-covered-ground-8882288/