-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsupabase_storage_fix.sql
More file actions
30 lines (26 loc) · 1.02 KB
/
supabase_storage_fix.sql
File metadata and controls
30 lines (26 loc) · 1.02 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
-- 1. community_images 버킷 생성 (이미 존재하면 무시)
insert into storage.buckets (id, name, public)
values ('community_images', 'community_images', true)
on conflict (id) do nothing;
-- 2. 정책(Policy) 설정 (Storage는 storage.objects 테이블을 사용합니다)
-- 2-1. 누구나 이미지 보기 (Select) 허용
drop policy if exists "Public Access" on storage.objects;
create policy "Public Access"
on storage.objects for select
using ( bucket_id = 'community_images' );
-- 2-2. 로그인한 유저만 이미지 업로드 (Insert) 허용
drop policy if exists "Authenticated Upload" on storage.objects;
create policy "Authenticated Upload"
on storage.objects for insert
with check (
bucket_id = 'community_images'
and auth.role() = 'authenticated'
);
-- 2-3. 자기 이미지 수정/삭제 (Update/Delete) 허용 (선택사항)
drop policy if exists "Owner Maintain" on storage.objects;
create policy "Owner Maintain"
on storage.objects for all
using (
bucket_id = 'community_images'
and auth.uid() = owner
);