Skip to content

Commit f07c5e0

Browse files
committed
[HotFix] API file upload logic update
1 parent 0401bf9 commit f07c5e0

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

sql/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@
1515
## 사용법
1616
각 SQL 파일은 해당 테이블의 CREATE TABLE 문을 포함합니다. 필요한 경우 psql 또는 Supabase Studio에서 실행하여 테이블을 복원할 수 있습니다.
1717

18-
> 정책, 함수, 인덱스 등은 별도 추출이 필요하며, 이 폴더에는 테이블 구조만 포함되어 있습니다.
18+
> 정책, 함수, 인덱스 등은 별도 추출이 필요하며, 이 폴더에는 테이블 구조만 포함되어 있습니다.
19+
>
20+
> **2024-06-10 기준**: `project_files.sql`, `project_images.sql`에는 RLS(행 수준 보안) 활성화 및 public select 정책이 포함되어 있습니다. 실제 Supabase 정책과 동기화됨을 참고하세요.

sql/project_files.sql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@ CREATE TABLE IF NOT EXISTS public.project_files (
77
created_at timestamptz DEFAULT now(),
88
PRIMARY KEY (id),
99
CONSTRAINT project_files_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id)
10-
);
10+
);
11+
12+
-- RLS 활성화 및 public select 정책
13+
ALTER TABLE public.project_files ENABLE ROW LEVEL SECURITY;
14+
CREATE POLICY "Allow read access to all for project_files" ON public.project_files
15+
FOR SELECT USING (true);

sql/project_images.sql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@ CREATE TABLE IF NOT EXISTS public.project_images (
77
created_at timestamptz DEFAULT now(),
88
PRIMARY KEY (id),
99
CONSTRAINT project_images_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id)
10-
);
10+
);
11+
12+
-- RLS 활성화 및 public select 정책
13+
ALTER TABLE public.project_images ENABLE ROW LEVEL SECURITY;
14+
CREATE POLICY "Allow read access to all for project_images" ON public.project_images
15+
FOR SELECT USING (true);

src/app/admin/members/page.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,10 @@ export default function MembersPage() {
329329
<label className="text-sm font-medium">프로필 이미지</label>
330330
<div className="flex items-center gap-4">
331331
{profileImagePreview ? (
332-
<Image src={profileImagePreview} alt="미리보기" className="w-16 h-16 rounded-full object-cover" width={64} height={64} />
332+
<>
333+
<Image src={profileImagePreview} alt="미리보기" className="w-16 h-16 rounded-full object-cover" width={64} height={64} />
334+
<p className="text-xs text-muted-foreground mt-1">이미지 선택 후 <b>멤버 추가</b>를 눌러야 반영됩니다.</p>
335+
</>
333336
) : null}
334337
<input
335338
type="file"
@@ -479,7 +482,10 @@ export default function MembersPage() {
479482
<label className="text-sm font-medium">프로필 이미지</label>
480483
<div className="flex items-center gap-4">
481484
{profileImagePreview ? (
482-
<Image src={profileImagePreview} alt="미리보기" className="w-16 h-16 rounded-full object-cover" width={64} height={64} />
485+
<>
486+
<Image src={profileImagePreview} alt="미리보기" className="w-16 h-16 rounded-full object-cover" width={64} height={64} />
487+
<p className="text-xs text-muted-foreground mt-1">이미지 선택 후 <b>저장</b>을 눌러야 반영됩니다.</p>
488+
</>
483489
) : editData.profile_image_url ? (
484490
<Image src={editData.profile_image_url} alt="기존 이미지" className="w-16 h-16 rounded-full object-cover" width={64} height={64} />
485491
) : null}

src/app/admin/projects/edit/[id]/page.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,11 @@ export default function EditProjectPage() {
473473
return;
474474
}
475475
}
476+
477+
// 2-1. 첨부파일 업로드 (newFiles가 있으면 자동 업로드)
478+
if (newFiles.length > 0) {
479+
await handleFileUpload();
480+
}
476481

477482
// 3. 프로젝트 태그 업데이트
478483
// 3-1. 기존 태그 삭제
@@ -834,9 +839,6 @@ export default function EditProjectPage() {
834839
onChange={handleFileChange}
835840
className="mb-2"
836841
/>
837-
<Button type="button" variant="outline" onClick={handleFileUpload} disabled={!newFiles.length}>
838-
파일 업로드
839-
</Button>
840842
{fileUploadProgress > 0 && (
841843
<div className="w-full bg-gray-200 rounded-full h-2.5 mt-2">
842844
<div className="bg-blue-600 h-2.5 rounded-full" style={{ width: `${fileUploadProgress}%` }}></div>

0 commit comments

Comments
 (0)