Skip to content

[Feat] S3 Presigned URL 이미지 업로드 코어 훅 구현 (useImageUpload) #15

Description

@IamInJINI

📝 개요

이미지 업로드 및 AI 분석 프로세스 진행을 위한 코어 커스텀 훅(useImageUpload)을 구현합니다.
백엔드 회의 결과에 따라 S3 Presigned URL 방식을 선제적으로 지원하며, 백엔드 API 명세가 최종 반영되기 전까지 팀원들의 원활한 UI 작업을 위해 시뮬레이션(Mocking) 형태로 동작하는 훅을 설계했습니다.

🛠️ 주요 작업 내용

  • 파일 유효성 검증 로직
    • 파일 용량 체크 (최대 5MB 제한)
    • 확장자 제한 (JPG, PNG, WEBP만 허용)
  • Presigned URL & S3 업로드 2단계 비동기 시뮬레이션
    • 1단계: 백엔드 Presigned URL 발급 대기 모킹
    • 2단계: S3 바이너리 PUT 전송 대기 모킹
  • 상태 관리 구조 확립
    • 업로드 상태(isUploading), 획득한 고유 ID(imageId), 에러 메시지(error) 관리
  • 업로드 실패 시 재시도 로직 구현
    • 마지막으로 실패한 파일 객체(lastFile)를 기억하여 즉시 재시도할 수 있는 retryUpload 구현

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions