Add storage policies for post_media bucket
cgen-cc02d60c869540d2809ca079dcd364e1
This commit is contained in:
parent
e30d528bc2
commit
aef065275e
1 changed files with 21 additions and 0 deletions
21
supabase/migrations/20251018_storage_post_media_policies.sql
Normal file
21
supabase/migrations/20251018_storage_post_media_policies.sql
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
-- Storage policies for post_media uploads
|
||||
begin;
|
||||
|
||||
-- Ensure RLS is enabled on storage.objects
|
||||
alter table if exists storage.objects enable row level security;
|
||||
|
||||
-- Allow public read for objects in post_media bucket (because bucket is public)
|
||||
DO $$ BEGIN
|
||||
CREATE POLICY IF NOT EXISTS post_media_public_read ON storage.objects
|
||||
FOR SELECT TO public
|
||||
USING (bucket_id = 'post_media');
|
||||
EXCEPTION WHEN duplicate_object THEN NULL; END $$;
|
||||
|
||||
-- Allow authenticated users to upload to post_media bucket
|
||||
DO $$ BEGIN
|
||||
CREATE POLICY IF NOT EXISTS post_media_auth_insert ON storage.objects
|
||||
FOR INSERT TO authenticated
|
||||
WITH CHECK (bucket_id = 'post_media');
|
||||
EXCEPTION WHEN duplicate_object THEN NULL; END $$;
|
||||
|
||||
commit;
|
||||
Loading…
Reference in a new issue