Automate Image and Video Uploads to Cloudinary with Node.js

Managing media uploads manually can be a pain β€” especially when you're dealing with hundreds of images and videos. Whether you're a content creator, developer, or business owner, storing media in the cloud should be fast, organized, and reliable.

That's where Cloudinary Uploader comes in.

Built with Node.js, this open-source tool automates the process of uploading images and videos from a local folder to Cloudinary. It supports batch processing, multi-format handling, retry logic, and more.

Let’s dive into how it works and how you can get started in minutes.


🌟 Why Use This Uploader?

Here’s what makes Cloudinary Uploader stand out:

  • πŸ”„ Bulk Upload: Upload dozens or even hundreds of media files in one go.

  • ☁️ Cloud Storage: Securely store media on Cloudinary.

  • 🧠 Smart Detection: Automatically detects and separates images from videos.

  • πŸ“¦ Batch Processing: Upload files in customizable batch sizes.

  • ♻️ Retry Mechanism: Automatically retries failed uploads.

  • πŸ“Š Detailed Summary: Get a clear report of success and failure rates.


βš™οΈ Features at a Glance

FeatureDescription
Supported FormatsImages: PNG, JPG, GIF, SVG, WebP, etc.

Videos: MP4, AVI, MOV, etc. | | Organized Uploads | Uploads are organized into images/ and videos/ folders in Cloudinary | | Retry Logic | Configurable retry attempts for failed uploads | | Batch Configuration | Upload files in batches (default: 10 per batch) | | CLI Monitoring | Real-time progress updates in the terminal |


πŸ“ Project Structure

cloudinary-uploader/
β”œβ”€β”€ images/           # Place your media files here
β”œβ”€β”€ index.js          # Main script
β”œβ”€β”€ .env              # Your Cloudinary credentials (not committed)
β”œβ”€β”€ .env.example      # Example for setting up your env file
β”œβ”€β”€ package.json      # Project metadata and dependencies
└── README.md         # Project documentation

πŸš€ Getting Started

1. Clone the Repository

git clone https://github.com/manthanank/cloudinary-uploader.git
cd cloudinary-uploader

2. Install Dependencies

npm install

3. Configure Environment Variables

Create a .env file based on the provided .env.example:

CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret

Find these credentials in your Cloudinary dashboard.


πŸ–ΌοΈ Uploading Media

  1. Place all your images and videos inside the images/ folder.

  2. Run the uploader:

npm start

You’ll see real-time logs like:

πŸ“ Found 150 media files to upload
πŸ–ΌοΈ  Images: 120
πŸŽ₯ Videos: 30
βš™οΈ  Processing in batches of 10 files
πŸ”„ Retry attempts: 3
...
πŸŽ₯ Uploaded video1.mp4 (video): https://res.cloudinary.com/demo/video/upload/videos/video1.mp4

πŸ› οΈ Customization Options

πŸ“ Batch Size & Retry Attempts

You can adjust these in index.js:

const BATCH_SIZE = 10;       // Upload 10 files per batch
const RETRY_ATTEMPTS = 3;    // Retry failed uploads 3 times
const RETRY_DELAY = 2000;    // Delay between retries (in ms)

βž• Add More File Types

To support additional formats, modify the extension arrays:

const IMAGE_EXTENSIONS = [...];
const VIDEO_EXTENSIONS = [...];

πŸ§ͺ Error Handling & Troubleshooting

ProblemSolution
❌ Folder not foundEnsure images/ exists
❌ Invalid credentialsCheck your .env file
❌ Upload failedCheck file format, size, internet connection
❌ Resource type errorVerify correct file extension

πŸ“Š Upload Summary

At the end of each run, you’ll see a detailed summary:

πŸ“Š Upload Summary:
πŸ–ΌοΈ  Images - βœ… Successful: 118, ❌ Failed: 2
πŸŽ₯ Videos - βœ… Successful: 30, ❌ Failed: 0
πŸ“ˆ Overall Success Rate: 98.7%

πŸ” Security Best Practices

  • Never commit your .env file to version control

  • Store your credentials securely (e.g., use CI/CD secrets in production)

  • Cloudinary uses secure URLs by default for all media


πŸ“¦ Tech Stack

  • Node.js: Core runtime

  • Cloudinary SDK: Media upload API

  • dotenv: Load environment variables

  • fs & path: File system utilities


πŸ§‘β€πŸ’» Contributing

Want to improve this project?

  1. Fork the repo

  2. Create a new feature branch

  3. Commit and push your changes

  4. Submit a pull request πŸš€


πŸ“˜ Final Thoughts

If you're tired of dragging and dropping files into a web dashboard, Cloudinary Uploader offers a powerful alternative. With just one command, you can upload hundreds of images and videos into organized Cloudinary folders β€” complete with progress tracking and error handling.

Give it a try and streamline your media management today.


πŸ”— GitHub Repository: manthanank/cloudinary-uploader πŸ§‘β€πŸ’» Author: Manthan Ankolekar


0
Subscribe to my newsletter

Read articles from Manthan Ankolekar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Manthan Ankolekar
Manthan Ankolekar

I am an intermediate learner, full-stack developer, and blogger.......