Overview
Studley AI uses Vercel Blob for storing user-uploaded files including:- Study documents (PDF, DOCX, TXT)
- Profile pictures
- Audio recordings
- Generated content exports
Vercel Blob Setup
Create Blob Store
- Go to your Vercel Dashboard
- Select your Studley AI project
- Navigate to Storage tab
- Click Create Database → Blob
- Name:
studley-uploads - Click Create
Connect to Project
- After creation, click Connect to Project
- Select your Studley AI project
- Choose environment:
- Production
- Preview
- Development (optional)
- Click Connect
BLOB_READ_WRITE_TOKEN to your environment variables.File Upload Implementation
Basic Upload API Route
Studley AI includes a generic upload endpoint:app/api/upload/route.ts
Avatar Upload
Specialized endpoint for profile pictures:app/api/upload-avatar/route.ts
Document Upload for AI Processing
app/actions.ts
Client-Side Upload
React Upload Component
components/FileUpload.tsx
Drag-and-Drop Upload
components/DragDropUpload.tsx
Blob Configuration Options
Access Control
- Public Access
- Private Access
- Profile pictures
- Public study materials
- Shared resources
Additional Options
File Processing
PDF Processing
Extract text from uploaded PDFs:DOCX Processing
Image Optimization
File Management
List Files
Delete Files
Copy Files
Security Best Practices
Validate File Types
Validate File Types
Always validate MIME types:
Limit File Sizes
Limit File Sizes
Enforce reasonable size limits:
Sanitize Filenames
Sanitize Filenames
Remove potentially dangerous characters:
Use User-Specific Paths
Use User-Specific Paths
Organize files by user:
Implement Rate Limiting
Implement Rate Limiting
Prevent upload spam:
Storage Limits
Vercel Blob Pricing
- Hobby (Free)
- Pro
Included:
- 100GB storage
- 1GB bandwidth/month
- Storage: $0.15/GB/month
- Bandwidth: $0.10/GB
Monitoring Usage
Track storage usage in Vercel Dashboard:- Go to Storage tab
- Select your Blob store
- View Usage metrics:
- Total files
- Storage used
- Bandwidth used
Troubleshooting
Upload fails with 401 Unauthorized
Upload fails with 401 Unauthorized
File upload timeout
File upload timeout
Error: Upload exceeds timeoutSolutions:
- Reduce file size before upload
- Compress images client-side
- Increase serverless function timeout (Pro plan)
- Use chunked uploads for large files
CORS errors on blob URLs
CORS errors on blob URLs
Error: CORS policy blocks accessSolutions:
- Blob URLs should work cross-origin by default
- Check browser console for specific error
- Ensure URL is correct and accessible
Storage quota exceeded
Storage quota exceeded
Error:
Storage limit reachedSolutions:- Review and delete old files
- Implement automatic cleanup of old uploads
- Upgrade Vercel plan
- Use alternative storage for large files
Alternative Storage Options
If Vercel Blob doesn’t fit your needs:AWS S3
Highly scalable, pay-as-you-go pricing
Cloudflare R2
S3-compatible, zero egress fees
Supabase Storage
Integrated with Supabase auth, RLS policies
UploadThing
Developer-friendly, simple integration
Next Steps
PDF Processing
Extract text from uploaded files
AI Generation
Use documents for AI generation
API Reference
View API endpoints
Admin Guide
Learn about security best practices