๐Ÿš€ Automate Media Uploads to Cloudinary with Node.js: A Complete Guide
Manthan Ankolekar

Manthan Ankolekar @manthanank

About: Software Developer | JavaScript | Angular | Nodejs | MongoDB | Express.js | Python | Firebase | MySQL | Postgresql |

Location:
Karnataka, India
Joined:
Feb 21, 2021

๐Ÿš€ Automate Media Uploads to Cloudinary with Node.js: A Complete Guide

Publish Date: Aug 7
1 0

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

Feature Description
Supported Formats Images: 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
Enter fullscreen mode Exit fullscreen mode

๐Ÿš€ Getting Started

1. Clone the Repository

git clone https://github.com/manthanank/cloudinary-uploader.git
cd cloudinary-uploader
Enter fullscreen mode Exit fullscreen mode

2. Install Dependencies

npm install
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

๐Ÿ› ๏ธ 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)
Enter fullscreen mode Exit fullscreen mode

โž• Add More File Types

To support additional formats, modify the extension arrays:

const IMAGE_EXTENSIONS = [...];
const VIDEO_EXTENSIONS = [...];
Enter fullscreen mode Exit fullscreen mode

๐Ÿงช Error Handling & Troubleshooting

Problem Solution
โŒ Folder not found Ensure images/ exists
โŒ Invalid credentials Check your .env file
โŒ Upload failed Check file format, size, internet connection
โŒ Resource type error Verify 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%
Enter fullscreen mode Exit fullscreen mode

๐Ÿ” 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


Comments 0 total

    Add comment