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
π 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
- Place all your images and videos inside the
images/
folder. - 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
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%
π 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?
- Fork the repo
- Create a new feature branch
- Commit and push your changes
- 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
Top comments (0)