Original working file
reference/delete-policy.sql
Code and working example pages keep their original identifiers and sample text. The lesson and file guidance explain them in your language.
-- Apply in the disposable project after the starter upload/read policies.
create policy "delete own avatar" on storage.objects for delete to authenticated
using (bucket_id='avatars' and (storage.foldername(name))[1]=auth.uid()::text);
-- Test a crafted cross-owner request too; client-side checks alone are not protection.