Installation
The Cloudinary driver is included by default with Directus via the@directus/storage-driver-cloudinary package.
Configuration
Configure Cloudinary storage using environment variables:Configuration Options
string
required
Your Cloudinary cloud name. Find this in your Cloudinary dashboard.
string
required
Your Cloudinary API key.
string
required
Your Cloudinary API secret.
'public' | 'authenticated'
required
Access mode for uploaded files.
public allows direct URL access, authenticated requires signed URLs.string
Optional path prefix for organizing files within Cloudinary.
boolean
Enable TUS resumable uploads. Default:
false.number
Chunk size for resumable uploads in bytes. Minimum:
5242880 (5 MiB). Only used when TUS is enabled.Examples
Basic Configuration
Authenticated Access
With Root Path
With Resumable Uploads
Features
Resource Types
Cloudinary automatically detects resource types from/packages/storage-driver-cloudinary/src/index.ts:96-101:
- Image -
.jpg,.png,.gif,.webp,.bmp,.svg,.ico,.heic - Video -
.mp4,.mov,.avi,.mkv,.webm,.flv,.m3u8 - Raw - All other file types
Resumable Uploads
The Cloudinary driver supports TUS resumable uploads from/packages/storage-driver-cloudinary/src/index.ts:25-519:
- Minimum chunk size: 5 MiB (enforced by Cloudinary)
- Chunks uploaded with unique upload ID
- Supports concurrent chunk uploads (max 10 concurrent)
- Automatic chunk accumulation for optimal size
Chunked Upload Implementation
From/packages/storage-driver-cloudinary/src/index.ts:256-347:
- Automatically splits streams into 5.5 MiB chunks
- Concurrent upload with queue management
- Content-Range headers for chunk positioning
- Unique upload ID for session tracking
Signed URLs
For authenticated mode, the driver generates signed URLs from/packages/storage-driver-cloudinary/src/index.ts:82-86:
- SHA-256 signature generation
- Parameter-based signatures for delivery
- Automatic signature verification by Cloudinary
Transformations
Cloudinary provides powerful URL-based transformations:- Image resizing, cropping, and effects
- Video transcoding and adaptive streaming
- Format conversion and optimization
- Face detection and content-aware cropping
Implementation Details
The Cloudinary driver (DriverCloudinary class) from /packages/storage-driver-cloudinary/src/index.ts:25-519:
- Uses SHA-256 for signature generation
- Implements chunked uploads with queue management
- Automatic resource type detection
- Public ID extraction (removes extensions for images/videos)
- Folder path handling for organization
Upload Process
- Files are automatically categorized by type
- Timestamp-based signatures prevent replay attacks
- Chunks uploaded with Content-Range headers
- Final chunk triggers Cloudinary processing
- Asset folder structure maintained
Best Practices
API Credentials
Securely manage your credentials:Access Mode
Choose the appropriate access mode:- Public - For publicly accessible content (blogs, marketing sites)
- Authenticated - For private content requiring signed URLs
Asset Organization
Use folders and tags for organization:Cloudinary Upload Presets
Create upload presets in Cloudinary dashboard for:- Automatic format conversion
- Quality optimization
- Automatic tagging
- Transformation defaults
Resource Management
From/packages/storage-driver-cloudinary/src/index.ts:107-112:
- Images and videos have extensions removed from public ID
- Raw files keep full filename with extension
- Folder paths separated from filename in API calls
Performance Optimization
- Use Cloudinary’s CDN for global delivery
- Enable auto-format for optimal file formats
- Implement lazy loading for images
- Use responsive images with transformations
- Cache transformed assets
Quota Management
Monitor your Cloudinary usage:- Transformations count
- Storage space
- Bandwidth usage
- API requests
Advanced Features
Image Transformations
Access transformed images via URL:Video Streaming
Cloudinary provides adaptive bitrate streaming:Auto-optimization
Enable automatic optimization in URLs:q_auto- Automatic qualityf_auto- Automatic format selectiondpr_auto- Device pixel ratio adjustment
Troubleshooting
Authentication Errors
- Verify cloud name, API key, and secret are correct
- Check for extra whitespace in credentials
- Ensure API access is enabled in Cloudinary dashboard
- Verify signature generation matches Cloudinary’s requirements
Upload Failures
- Check file type is supported
- Verify account has available quota
- Ensure chunk size is at least 5 MiB
- Check Cloudinary service status
Invalid Chunk Size Error
From/packages/storage-driver-cloudinary/src/index.ts:40-42:
- Minimum chunk size is 5 MiB (5242880 bytes)
- Reduce if using larger value causing issues
- Increase for better performance with large files
Public ID Issues
- Special characters may need URL encoding
- Public IDs have length limits (255 characters)
- Forward slashes create folder structure
- Extensions handled differently by resource type
Signed URL Access
For authenticated mode:- Ensure signature parameter is included
- Check timestamp hasn’t expired
- Verify access mode configuration matches
- Test with Cloudinary’s URL debugger
Rate Limiting
If experiencing rate limits:- Reduce concurrent upload queue size
- Implement retry logic with exponential backoff
- Upgrade Cloudinary plan for higher limits
- Optimize upload patterns
Cloudinary Dashboard
Access advanced features in the Cloudinary dashboard:- Media library browser
- Transformation builder
- Upload presets
- Add-ons (AI, auto-tagging, etc.)
- Analytics and reports