|
|
# Create the `avatars` storage bucket
|
|
|
|
|
|
If you see **"Bucket not found"** when saving a profile with an uploaded image, the `avatars` bucket does not exist yet. Create it once using one of the methods below.
|
|
|
|
|
|
## Option 1: Supabase Dashboard (recommended)
|
|
|
|
|
|
1. Open your project: **https://supabase.com/dashboard** (or your self‑hosted URL, e.g. `https://supa1.satoshinakamoto.win`).
|
|
|
2. Go to **Storage** in the left sidebar.
|
|
|
3. Click **New bucket**.
|
|
|
4. Set:
|
|
|
- **Name:** `avatars` (must be exactly this).
|
|
|
- **Public bucket:** **ON** (so avatar URLs work without signed links).
|
|
|
- **File size limit:** `2` MB (optional).
|
|
|
- **Allowed MIME types:** `image/jpeg`, `image/png`, `image/gif`, `image/webp` (optional).
|
|
|
5. Click **Create bucket**.
|
|
|
|
|
|
Then add policies so users can upload only to their own folder and everyone can read:
|
|
|
|
|
|
1. Open the **avatars** bucket.
|
|
|
2. Go to **Policies** (or **Storage** → **Policies**).
|
|
|
3. Add policies equivalent to the ones in `supabase/migrations/20250213200000_profiles_avatar_and_storage.sql` (from the line `-- RLS: allow authenticated users...` onward), or run that part of the migration in the SQL Editor.
|
|
|
|
|
|
## Option 2: SQL Editor (if your Supabase allows it)
|
|
|
|
|
|
Run in **SQL Editor**:
|
|
|
|
|
|
```sql
|
|
|
INSERT INTO storage.buckets (id, name, public, file_size_limit, allowed_mime_types)
|
|
|
VALUES (
|
|
|
'avatars',
|
|
|
'avatars',
|
|
|
true,
|
|
|
2097152,
|
|
|
ARRAY['image/jpeg', 'image/png', 'image/gif', 'image/webp']
|
|
|
)
|
|
|
ON CONFLICT (id) DO NOTHING;
|
|
|
```
|
|
|
|
|
|
If you get an error (e.g. column names or schema differ), use **Option 1** instead.
|
|
|
|
|
|
After the bucket exists, run the **storage RLS policies** from `supabase/migrations/20250213200000_profiles_avatar_and_storage.sql` (the `CREATE POLICY` statements for `storage.objects`) so uploads and public read work correctly.
|