Overview
SkillRise uses Cloudinary for media asset management. Educators can upload course thumbnails and other media files, which are stored and optimized by Cloudinary.Features
- Image uploads: Course thumbnails and profile pictures
- Automatic optimization: Cloudinary optimizes images for web delivery
- CDN delivery: Fast global content delivery
- Transformations: Resize, crop, and format images on-the-fly
- Secure uploads: Signed upload requests
Environment Variables
Add these to yourserver/.env file:
server/.env
Get your credentials from the Cloudinary Console. They’re displayed on your dashboard home page.
Setup Instructions
Create Cloudinary Account
- Go to Cloudinary
- Sign up for a free account
- Free tier includes:
- 25GB storage
- 25GB bandwidth/month
- 25,000 transformations/month
Get API Credentials
- Log in to Cloudinary Console
- On the dashboard, you’ll see:
- Cloud Name
- API Key
- API Secret
- Click “Reveal API Secret” to view the secret
- Copy all three values
Configuration
Initialize Cloudinary in your server:server/configs/cloudinary.js
server/server.js
Upload Configuration
SkillRise uses Multer for handling multipart/form-data uploads:server/configs/multer.js
Upload Implementation
Backend Upload Handler
server/controllers/educatorController.js
server/routes/educatorRoutes.js
Frontend Upload Component
client/src/components/ThumbnailUpload.jsx
Image Transformations
Cloudinary supports on-the-fly transformations via URL parameters:Responsive Images
Common Transformations
| Transformation | URL Parameter | Example |
|---|---|---|
| Resize width | w_400 | 400px width |
| Resize height | h_300 | 300px height |
| Crop | c_fill | Fill area, crop excess |
| Quality | q_auto | Auto quality optimization |
| Format | f_auto | Auto format (WebP, AVIF) |
| Gravity | g_face | Focus on faces |
| Radius | r_20 | Rounded corners (20px) |
Transformation Examples
Organize Assets with Folders
Organize uploads by type:Delete Assets
Delete old images when updating:Signed Uploads (Advanced)
For direct browser-to-Cloudinary uploads (bypassing your server):server/routes/educatorRoutes.js
File Size Limits
Free Tier Limits
- File size: 10MB per file
- Video length: 100MB (not applicable for SkillRise images)
- Monthly bandwidth: 25GB
Recommended Limits
Set reasonable limits in Multer config:Common Issues
Upload fails with 'Invalid API key'
Upload fails with 'Invalid API key'
- Verify
CLOUDINARY_API_KEYandCLOUDINARY_SECRET_KEYare correct - Check that you’ve copied the values from the correct cloud name
- Ensure there are no extra spaces or quotes in
.envfile
Image not displaying
Image not displaying
- Verify the URL starts with
https://res.cloudinary.com/ - Check browser console for CORS errors
- Ensure the image was uploaded successfully (check Cloudinary Media Library)
File upload returns 413 Payload Too Large
File upload returns 413 Payload Too Large
- Check Multer
fileSizelimit (default 10MB) - Verify Cloudinary account limits
- Compress images before uploading
Transformations not working
Transformations not working
- Ensure transformation params are in the correct format
- Check for typos in parameter names
- Verify transformations are placed after
/upload/in the URL
Best Practices
Optimize Images
Always use
q_auto,f_auto for automatic quality and format optimization.Use Folders
Organize assets by type (thumbnails, avatars, content) for easier management.
Set Limits
Enforce file size and type limits to prevent abuse and storage bloat.
Delete Old Files
Remove old images when updating to save storage and bandwidth.