What You’ll Learn
- Upload files to Supabase Storage
- Download and display files
- Implement resumable uploads for large files
- Apply image transformations
- Set up access control policies
- Handle file metadata
Prerequisites
- A Supabase project
- Basic understanding of JavaScript/TypeScript
- Supabase client library installed
Storage Basics
Supabase Storage organizes files in buckets. Each bucket can have:- Public or private access
- Custom file size limits
- Allowed MIME types
- Storage policies for access control
Create a Storage Bucket
In your Supabase Dashboard:
- Navigate to Storage
- Click New bucket
- Configure your bucket:
- Name:
uploads(or your preferred name) - Public bucket: Toggle on for public access
- File size limit: Set as needed (e.g., 50MB)
- Allowed MIME types: Leave empty or specify types
- Name:
- Click Create bucket
Resumable Upload with Uppy
For large files, use resumable uploads with Uppy:Install dependencies:Create the component:
Advanced Features
Image Transformations
Supabase Storage supports on-the-fly image transformations:File Metadata
Store custom metadata with files:Signed URLs
Create temporary signed URLs for private files:Best Practices
File Naming
Use unique filenames to avoid conflicts. Consider using UUIDs or timestamps.
File Size Limits
Set appropriate file size limits in your bucket settings and validate on the client.
MIME Type Validation
Restrict allowed file types to prevent malicious uploads.
Folder Organization
Organize files in folders using paths like
userId/filename.ext.Error Handling
Always handle errors gracefully and provide user feedback.
Next Steps
Storage Policies
Learn about advanced access control
Image Transformations
Master image manipulation
User Management
Build complete user profiles
Storage Examples
Explore more storage examples
