Skip to content

Conversation

@yurim830
Copy link
Collaborator

@yurim830 yurim830 commented Sep 21, 2025

🐿️ Pull Requests

🪵 작업 브랜치

🥔 작업 내용

PresignedURL API 수정사항 반영

  1. GET → POST로 변경
  2. Query Parameter → Request Body로 변경
  3. Request Body로 originalFileName도 전달 (이미지 확장자 검증 용도)
  4. jpg 외에도 각 ImageType 별로 다른 이미지 확장자들도 사용 가능
  5. Response Body 필드명 변경: fileName → fileUrl

PhotoManager 구현

PhotoManager를 구현하여, presignedURL 처리를 간편하게 하고, 성능을 개선했습니다.

기존

  • ViewModel이 presigned URL 발급 → 이미지 변환 → S3 업로드 → 게시물 등록까지 모두 직접 처리 (=> 여러 화면에서 로직 중복)
  • 중첩된 completion handler로 가독성 저하 및 유지보수 어려움
  • JWT 만료 시 재귀 호출로 무한 루프 위험
  • UIImage만 전달하는 기존 구조: PHAsset 정보가 손실되어 화질 및 포맷 불안정함

개선

  • PhotoManager로 사진 업로드 전 과정 통합
    →ViewModel은 await PhotoManager.uploadImages()만 호출 (관심사 분리)
  • PhotoModel로 원본 PHAsset 보존
  • ImageType으로 업로드 대상별 허용 UTI / 압축률 관리
  • Swift Concurrency + TaskGroup으로 병렬 업로드, 속도 개선
    • 기존 DispatchGroup + 중첩 콜백 제거
  • PhotoManagerError로 에러 명확히 핸들링, JWT 재발급 재시도 1회 제한 → 무한 루프 방지

🚨 참고 사항

서버 로직 문제로 presignedURL 획득 과정에서 401에러가 나고 있는데,
이때 우리 프로젝트 구조상, handleReissue 로 빠져, 네트워킹을 재시도하는 무한 루프에 빠지게 됩니다.
과금 방지를 위해, 최대 1번만 재시도하고, 실패 시 다음에 시도하라는 Alert을 띄워, TabBar로 이동을 유도했습니다. (gif 1 참고)

📸 스크린샷

기능 스크린샷 기능 스크린샷 기능 스크린샷
아이폰 16 Pro 아이폰 13 mini 아이폰 se

💥 To be sure

  • 모든 뷰가 잘 실행되는지 다시 한 번 체크해주세요 !

🌰 Resolve issue

@cirtuare cirtuare self-requested a review September 22, 2025 01:37
Copy link
Contributor

@cirtuare cirtuare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PhotoManager 좋다 !!! 리뷰만 한 번 확인 부탁드립니당 👍💗

continuation.resume(throwing: PhotoManagerError.tokenExpired)
case .requestErr(let errorResponse):
continuation.resume(throwing: errorResponse)
case .decodedErr, .pathErr, .serverErr, .networkFail, .naverAPIErr:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐿️🐿️
그냥 default로 처리해도 좋을 것 같아요!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

근데 네트워크와 상관없는 서버 에러도 networkError 타입으로 처리하는 이유가 있나요?!

Comment on lines 69 to 74
} catch {
handleNetworkError { [weak self] in
self?.executeUploadFlow()
}
print("❌ A failure occurred during the upload process: \(error.localizedDescription)")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐿️🐿️🐿️
이 handleNetworkError가 networkFail 시에만 호출되어야 하는데, 지금 catch에 별다른 타입 지정이 없어 tokenExpired이 아닌 에러의 경우 모두 handleNetworkError가 호출되고 있는 것 같아요
networkFail와 다른 에러들을 구분해주는 게 좋을 것 같습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

에러 핸들링 세분화했습니다! 피드백 감사해용

@yurim830 yurim830 merged commit 16efb80 into develop Sep 22, 2025
@yurim830 yurim830 self-assigned this Sep 22, 2025
@yurim830 yurim830 added 🌀 feature 새로운 기능 개발 🍀 refactor 리팩토링 🥑 유림 유림 labels Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌀 feature 새로운 기능 개발 🍀 refactor 리팩토링 🥑 유림 유림

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] PresignedURL API 로직 수정, PhotoManager 구현

3 participants