Uploadcare
Automated image optimization & virus scanning
Intelligent file CDN with smart image optimization and automatic virus scanning. Transform images on-the-fly without extra infrastructure.
How it works
Files are uploaded to Uploadcare's intelligent CDN, automatically optimized, and scanned for threats before delivery.
⚙️Setup
Initialize the ObitoX client with your Uploadcare credentials
1import ObitoX from '@obitox/upload';23const client = new ObitoX({4 apiKey: process.env.OBITOX_API_KEY,5 apiSecret: process.env.OBITOX_API_SECRET6});78const uploadcare = client.uploadcare({9 publicKey: process.env.UPLOADCARE_PUBLIC_KEY,10 secretKey: process.env.UPLOADCARE_SECRET_KEY11});
Operations
Smart Upload
Upload with auto-optimization
Transform
Resize, crop, filter on-the-fly
Virus Scan
Server-side malware check
Magic Bytes
Validate content type (Client-side)
Webhooks
Upload completion events
Fast CDN
Global delivery network
Delete Files
Remove files from storage
Optimization
Advanced compression settings
Upload Features
📤Basic Upload
1const fileUrl = await uploadcare.upload(file, {2 filename: 'photo.jpg'3});45console.log(fileUrl); // https://ucarecdn.com/uuid/photo.jpg
✨Auto Image Optimization
Automatically convert to WebP/AVIF and optimize quality
1const fileUrl = await uploadcare.upload(file, {2 filename: 'photo.jpg',3 imageOptimization: { auto: true }4});
🛠️Manual Optimization
Fine-tune compression and format settings
1const fileUrl = await uploadcare.upload(file, {2 filename: 'photo.jpg',3 imageOptimization: {4 format: 'webp',5 quality: 'best',6 progressive: true,7 stripMeta: 'all',8 adaptiveQuality: true9 }10});
| Option | Values | Description |
|---|---|---|
format | auto, webp, jpeg, png | Output image format |
quality | lightest to best | Compression level |
adaptiveQuality | true/false | AI quality optimization |
📊Progress Tracking
Monitor upload progress in real-time
1const fileUrl = await uploadcare.upload(file, {2 filename: 'photo.jpg',3 onProgress: (percent, uploaded, total) => {4 console.log(`${percent}% — ${uploaded}/${total} bytes`);5 }6});
🕵️Magic Bytes Validation
Validate file content matches extension
1const url = await uploadcare.upload(file, {2 filename: 'photo.jpg',3 validation: 'images'4});
Validation presets: 'images' | 'documents'
Virus Scanning
🦠Scan & Delete
Automatically detect and remove infected files
1const fileUrl = await uploadcare.upload(file, {2 filename: 'document.pdf',3 checkVirus: true4});5// Infected files are automatically rejected
On-the-fly Transformations
🎨URL-Based Processing
Transform images just by changing the URL
Resize
Convert Format
Crop & Quality
Download & CDN
🌍Get CDN URL
Publicly accessible CDN link
1const downloadUrl = await uploadcare.download({2 fileUrl: 'https://ucarecdn.com/uuid/photo.jpg'3});
🗑️Delete File
1await uploadcare.delete({2 fileUrl: 'https://ucarecdn.com/uuid/photo.jpg'3});
Webhooks
Notification system for upload completion.
⚡Auto Trigger
Server confirms automatically
1const url = await uploadcare.upload(file, {2 filename: 'report.jpg',3 webhook: {4 url: 'https://myapp.com/webhooks/upload',5 trigger: 'auto',6 metadata: { userId: 'user_456' }7 }8});
👆Manual Trigger
You confirm when ready
1const url = await uploadcare.upload(file, {2 filename: 'invoice.jpg',3 webhook: {4 url: 'https://myapp.com/webhooks/upload',5 secret: 'webhook_secret_123',6 trigger: 'manual',7 autoConfirm: false,8 metadata: { userId: 'user_123', uploadType: 'test' }9 }10});11// Then call /webhooks/confirm to trigger delivery
Upload Cancellation
🛑Best-Effort Cancellation
Cancel uploads in progress
Cancellation is best-effort — small files on fast connections may complete before the abort takes effect.
1const abortController = new AbortController();23try {4 const uploadPromise = uploadcare.upload(largeFile, {5 filename: 'large-photo.jpg',6 onProgress: (progress) => {7 if (progress > 50) abortController.abort();8 }9 });10 setTimeout(() => abortController.abort(), 5000);11 const url = await uploadPromise;12} catch (error) {13 if (error.name === 'AbortError') console.log('Upload cancelled');14}
That's it!
No more manual handling.
Viruses are scanned, images are optimized, and content is distributed globally—automatically.
Focus on building your app, we handle the rest.