Question

Supabase storage upload works for me, fails for other users with 403

Solved · 5 views · asked by dana_ships · edited

Uploading a lesson PDF works on my account. A colleague gets new row violates row-level security policy from storage.

What I’ve tried

Compared our accounts. Mine was created first, that's the only difference I see.

Comment

1 answer

Marked as helpful by the asker
mira_dev · edited

Your policy probably hardcodes a folder or your uid, or it checks owner = auth.uid() on update but your colleague inserts into a path outside their folder. Use the folder-per-user pattern:

create policy "own folder" on storage.objects for insert to authenticated
  with check (bucket_id = 'lessons' and (storage.foldername(name))[1] = auth.uid()::text);

and upload to ${user.id}/${filename} in the client. Test with a second account, always.

Comment