Basic File Operations
Upload a File
Download a File
List Files
Delete Files
Working with Buckets
Buckets are containers for files with access policies:- Public Buckets - Files accessible without authentication
- Private Buckets - Files require authentication token
Bucket creation is admin-only. Regular users upload to existing buckets.
Public File Access
Private File Access
Image Upload Example
Complete example for avatar upload with preview:File Upload Progress
Track upload progress for large files:React Component Example
Storage Patterns
User Avatars
Store in
avatars
bucket with user ID prefixProduct Images
Public bucket for catalog images
Documents
Private bucket with access control
Temp Files
Auto-cleanup with lifecycle rules
Error Handling
Storage operations return structured errors:Best Practices
- Use
uploadAuto()
for automatic unique filenames - Organize with prefixes like
user-{id}/
for better structure - Validate file types before uploading
- Set size limits appropriate for your use case
- Use public buckets for assets, private for sensitive files
- Clean up unused files to manage storage costs