Overview
JOIP Web Application uses Supabase Storage for all file uploads, including user media, session thumbnails, community content, and manual session images. This guide covers complete setup, bucket configuration, access policies, and troubleshooting.Why Supabase Storage?
Supabase Storage is the primary file storage solution for JOIP because:- CDN Distribution: Global content delivery network for fast access
- Automatic Scaling: No file count or bucket limits
- S3-Compatible API: Standard object storage interface
- Built-in Image Optimization: Automatic resizing and transformations
- Public/Private Buckets: Flexible access control
- Generous Free Tier: 1 GB storage, 2 GB bandwidth per month
- Direct Integration: Works seamlessly with JOIP’s architecture
Prerequisites
- Supabase account (free or paid)
- Basic understanding of object storage concepts
- Access to Replit Secrets or environment variables
Supabase Project Setup
Create Supabase Account
- Visit supabase.com
- Click “Start your project”
- Sign up with GitHub/Google/email
- Verify your email address
Create New Project
- Click “New Project” in Supabase dashboard
- Configure your project:
- Organization: Select or create organization
- Project Name:
joip-production(or your preferred name) - Database Password: Generate strong password (save this!)
- Region: Choose closest to your users (e.g., US East)
- Pricing Plan: Free (upgrade later as needed)
- Click “Create new project”
- Wait 2-3 minutes for provisioning
Retrieve API Credentials
After project creation:
- Navigate to Settings → API
- Copy the following values:
- Project URL:
https://xyzabcdefg123456.supabase.co - anon public key:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... - service_role secret key:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
- Project URL:
Storage Bucket Configuration
JOIP uses two primary storage buckets:1. user-media Bucket
Purpose: Stores user-specific uploads- Manual session images
- Media vault files
- Session thumbnails
2. general Bucket
Purpose: Stores community-shared content- Community session snapshots
- Shared media copies
- Public resources
Create Buckets
Access Storage Dashboard
- Open your Supabase project
- Navigate to Storage in left sidebar
- Click “Create a new bucket”
Create user-media Bucket
Configure the first bucket:
- Name:
user-media - Public bucket: ✓ Enabled (for CDN access)
- File size limit: 100 MB (or your preference)
- Allowed MIME types: Leave empty (all types allowed)
JOIP automatically creates these buckets on first startup if they don’t exist (
server/supabase.ts). Manual creation is recommended for production.Storage Policies
Supabase uses Row Level Security (RLS) policies for access control. For public buckets, configure policies:user-media Bucket Policies
general Bucket Policies
JOIP uses the service_role key for server-side storage operations, which bypasses RLS policies. Client policies are for direct Supabase client usage (not currently used in JOIP).
File Upload Implementation
JOIP implements file uploads using in-memory buffers with Multer and Sharp for image processing.Upload Flow
Server-Side Upload (server/upload.ts)
Upload to Supabase (server/supabase.ts)
File Management Operations
Upload File
Delete File
Delete Folder (Session Cleanup)
Copy File Between Buckets
Storage Diagnostics
JOIP provides a storage status endpoint for troubleshooting:Check Storage Health
Common Status Codes
STORAGE_CONFIG_ERROR: Missing environment variablesSTORAGE_UNREACHABLE: Cannot connect to SupabaseSTORAGE_PREFLIGHT_FAILED: Bucket creation/access failedUPLOAD_FAILED: Test upload failed
Image Optimization
Supabase Storage supports automatic image transformations via URL parameters:Resize Image
Quality Adjustment
Format Conversion
Combined Transformations
Image transformations are cached at the CDN edge for optimal performance.
Monitoring and Limits
Storage Usage
Monitor storage usage in Supabase dashboard:- Open your project
- Navigate to Settings → Usage
- View:
- Total storage used
- Bandwidth consumed
- API requests count
- Active connections
Free Tier Limits
- Storage: 1 GB
- Bandwidth: 2 GB/month
- API requests: Unlimited (rate-limited)
- File size: 50 MB (configurable up to 5 GB on paid plans)
Paid Plan Upgrades
Supabase Pro plan ($25/month) includes:- 100 GB storage
- 200 GB bandwidth
- No pausing due to inactivity
- Priority support
- Increased file size limits (5 GB)
Troubleshooting
Storage Unreachable (503 Errors)
Symptom: Manual session uploads fail withSTORAGE_UNREACHABLE
Cause: Supabase project is paused (free tier inactivity)
Solution:
- Log in to Supabase dashboard
- Navigate to your project
- Click “Resume Project” (green button)
- Wait 1-2 minutes for project to wake up
- Test with
GET /api/storage/status
Missing Buckets
Symptom: Upload fails with “Bucket not found” error Solution:- Check bucket names:
user-mediaandgeneral(case-sensitive) - Manually create buckets in Supabase dashboard
- Restart JOIP application to auto-create
- Verify bucket creation with storage status endpoint
CORS Errors
Symptom: Browser console shows CORS policy errors Solution:- Ensure buckets are marked as “Public”
- Add allowed origins in Supabase Authentication → URL Configuration:
- Clear browser cache and retry
File Size Limit Errors
Symptom: Upload fails with “File too large” error Solution:- Check client-side validation (100 MB default)
- Adjust Multer limit in
server/upload.ts: - Update Supabase bucket settings (dashboard)
- Consider compressing images before upload
Invalid File Type
Symptom: Upload rejected with “Invalid file type” error Solution:- Check allowed MIME types in
server/upload.ts - Add additional types if needed:
- Restart application
Slow Upload Performance
Symptom: Uploads take unusually long time Solutions:- Check Supabase Region: Use region closest to users
- Enable Image Compression: Use Sharp to compress before upload:
- Upgrade Supabase Plan: Pro plan offers better performance
- Monitor Network: Check for ISP throttling or network issues
Orphaned Files
Symptom: Files remain in storage after deleting database records Prevention:- Always delete storage files before database records
- Use database transactions to ensure atomicity
- Implement cleanup jobs for orphaned files
Security Best Practices
Filename Sanitization
Path Validation
Performance Optimization
CDN Caching
Supabase Storage uses Cloudflare CDN with automatic caching:- Static Assets: Cached for 1 year
- Dynamic Content: Respect
Cache-Controlheaders - Purging: Automatic on file update/delete
Lazy Loading
Implement lazy loading for images:Batch Operations
Batch uploads and deletes for better performance:Next Steps
Deploy on Replit
Deploy your configured storage to Replit
Environment Variables
Complete environment variable reference
Database Setup
Configure PostgreSQL database