-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupabase_storage_posts.sql
More file actions
39 lines (33 loc) · 1.21 KB
/
supabase_storage_posts.sql
File metadata and controls
39 lines (33 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
-- Supabase Storage setup for post images
-- Run in Supabase SQL editor.
insert into storage.buckets (id, name, public)
values ('post-images', 'post-images', true)
on conflict (id) do update set public = excluded.public;
drop policy if exists "Public can read post images" on storage.objects;
drop policy if exists "Users can upload own post images" on storage.objects;
drop policy if exists "Users can update own post images" on storage.objects;
drop policy if exists "Users can delete own post images" on storage.objects;
create policy "Public can read post images"
on storage.objects for select
using (bucket_id = 'post-images');
create policy "Users can upload own post images"
on storage.objects for insert
with check (
bucket_id = 'post-images'
and auth.uid() is not null
and split_part(name, '/', 1) = auth.uid()::text
);
create policy "Users can update own post images"
on storage.objects for update
using (
bucket_id = 'post-images'
and auth.uid() is not null
and split_part(name, '/', 1) = auth.uid()::text
);
create policy "Users can delete own post images"
on storage.objects for delete
using (
bucket_id = 'post-images'
and auth.uid() is not null
and split_part(name, '/', 1) = auth.uid()::text
);