Which statement best describes the purpose of storage policies in Supabase?
Think about what access control means for stored files.
Storage policies in Supabase specify which users or roles can perform actions like upload, download, or delete on storage buckets or files.
Which Supabase storage policy allows only authenticated users to upload files to a bucket?
CREATE POLICY "Allow authenticated uploads" ON storage.objects FOR INSERT WITH CHECK (auth.role() = 'authenticated');
Look for a policy that uses FOR INSERT and checks the authenticated role.
The policy must be FOR INSERT to allow uploads and use WITH CHECK clause to check the user's role is 'authenticated'.
You want to create two buckets: one public for images anyone can view, and one private for user documents only the owner can access. Which policy setup achieves this?
Public means anyone can view, private means only owner can do everything.
Public bucket must allow anyone to read (SELECT). Private bucket must restrict all actions to the owner only.
Which policy prevents users from deleting files they do not own in a Supabase storage bucket?
Check for a policy that compares user ID with file owner.
Only the owner should be allowed to delete their files, so the policy must check auth.uid() equals the owner field.
If a Supabase storage bucket has no policies defined, what happens when a user tries to download a file?
Think about default security behavior when no policies exist.
Supabase storage denies all access by default unless policies explicitly allow it.
