Supabase Storage
Supabase Storage lets you upload files, images, and documents. Perfect for user avatars, photo uploads, and any file your app needs to store.Prerequisites
- Supabase connected
- Basic understanding of file handling
Storage Concepts
Buckets
Buckets are containers for your files — like folders at the top level. Examples:avatars— User profile photosuploads— User-uploaded contentdocuments— PDFs and files
Objects
Objects are the actual files inside buckets. Each has:- A unique path (e.g.,
avatars/user123.jpg) - Metadata (size, type, etc.)
- Access permissions
Creating a Bucket
In Supabase Dashboard
- Go to Storage in sidebar
- Click Create a new bucket
- Name it (e.g.,
avatars) - Choose public or private
Public vs Private
| Type | Use Case | Access |
|---|---|---|
| Public | Profile photos, shared media | Anyone with URL |
| Private | User documents, sensitive files | Requires auth |
Uploading Files
Basic Upload
Ask Nativeline:Upload Code Pattern
Organizing Files
By User
By Content Type
Getting File URLs
Public Buckets
Private Buckets
Downloading Files
Deleting Files
Storage Security
Bucket Policies
Like RLS for database, set policies for storage: Allow users to upload to their own folder:Setting Policies in Dashboard
- Storage → Select bucket
- Policies tab
- Add new policy
- Choose template or write custom
Common Use Cases
Profile Photo Upload
Document Upload
Image Gallery
File Size and Types
Limits
- Default max file size: 50 MB
- Can be increased in settings
Accepted Types
By default, all types are accepted. You can restrict in bucket settings.Compression
Best Practices
Compress images before upload
Compress images before upload
Large images use storage and bandwidth. Compress and resize before uploading.
Use unique file names
Use unique file names
Include user ID and timestamp to avoid conflicts:
user-123/1704067200-photo.jpgSet appropriate bucket policies
Set appropriate bucket policies
Private buckets need policies. Public buckets are open — use carefully.
Handle upload failures
Handle upload failures
Show progress, handle errors gracefully, allow retry.
Troubleshooting
Upload failing
Upload failing
- Check bucket exists
- Verify policies allow upload
- Check file size limits
- Ensure user is authenticated (for private buckets)
Can't access file
Can't access file
- Public bucket? Use
getPublicURL - Private bucket? Use
createSignedURL - Check RLS policies
Slow uploads
Slow uploads
- Compress images before upload
- Use appropriate quality settings
- Check network connection