A Node.js Express application for handling file uploads with support for both local storage and Cloudinary cloud storage. Supports single and multiple file uploads.
- ✅ Single file upload to local storage
- ✅ Single file upload to Cloudinary
- ✅ Multiple file uploads to local storage
- ✅ Multiple file uploads to Cloudinary
- ✅ MongoDB integration for storing file metadata
- ✅ Buffer-based file processing
- Node.js - Runtime environment
- Express.js - Web framework
- Multer - File upload middleware
- Cloudinary - Cloud storage service
- MongoDB - Database
- Mongoose - MongoDB ODM
- Node.js (v14 or higher)
- MongoDB (running locally or remote connection)
- Cloudinary account (Sign up here)
cloudinary-multer/
├── src/
│ ├── models/
│ │ ├── singleLocal.js
│ │ ├── singleCloud.js
│ │ ├── multipleLocal.js
│ │ └── multipleCloud.js
│ └── multer/
│ ├── singleLocal.js
│ ├── singleCloud.js
│ ├── multipleLocal.js
│ ├── multipleCloud.js
│ └── bufferGenerator.js
├── upload/ # Local file storage
├── routs.js # Single upload routes
├── multipleUploadsrouter.js # Multiple upload routes
├── index.js # Main server file
├── .env # Environment variables
└── package.json
Important: All files must use the same key name files
The server will start on `http://localhost:5000`
## Accessing Uploaded Files
Local files are accessible at:
http://localhost:5000/uploads/
## Environment Variables
| Variable | Description |
|----------|-------------|
| `CLOUD_NAME` | Your Cloudinary cloud name |
| `API_KEY` | Your Cloudinary API key |
| `API_SECRET` | Your Cloudinary API secret |
## Dependencies
```json
{
"express": "^4.x.x",
"mongoose": "^7.x.x",
"multer": "^1.x.x",
"cloudinary": "^1.x.x",
"dotenv": "^16.x.x"
}