Skip to content

[Feat] #30 이력서/자소서 Presigned URL 업로드 기능 구현#33

Merged
yukyoungs merged 13 commits into
developfrom
feat/#30
Jul 22, 2026
Merged

[Feat] #30 이력서/자소서 Presigned URL 업로드 기능 구현#33
yukyoungs merged 13 commits into
developfrom
feat/#30

Conversation

@yukyoungs

@yukyoungs yukyoungs commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

#️⃣ 관련 이슈

closed #30

PR 유형

어떤 변경 사항이 있나요?

  • 새로운 기능 추가
  • 버그 수정
  • 코드 리팩토링
  • 주석 추가 및 수정
  • 문서 수정
  • 테스트 추가, 테스트 리팩토링
  • 빌드 부분 혹은 패키지 매니저 수정
  • 파일 혹은 폴더명 수정
  • 파일 혹은 폴더 삭제

PR Checklist

PR이 다음 요구 사항을 충족하는지 확인하세요.

  • 커밋 메시지 컨벤션에 맞게 작성했습니다.
  • 변경 사항에 대한 테스트를 했습니다.(버그 수정/기능에 대한 테스트).

🧩 작업 내용

  • AWS SDK S3 의존성 추가 및 S3Config, AwsS3Properties로 Presigned URL 발급 설정 구성
  • Resume 엔티티를 유형별(category) 1슬롯 구조로 변경 (user_id + category unique 제약, s3Key 기반으로 파일 경로 관리)
  • ResumeCategory, ResumeFileFormat enum 및 ResumeRepository 추가
  • 이력서/자소서 파일 업로드 API 구현 (/api/profile/files)
    • POST /presigned-url : 업로드용 Presigned URL 발급
    • POST : 업로드 완료 확인 및 파일 정보 저장 (같은 카테고리 재업로드 시 기존 row 갱신)
    • GET : 업로드된 파일 목록 조회
    • DELETE /{fileId} : 파일 삭제
  • Resume 관련 에러/성공 코드(ErrorStatus, SuccessStatus) 추가

📸 스크린샷(선택)

📣 To Reviewers

  • Reviewers : 팀 선택
  • Labels : 작업 유형, 자기 자신

Summary by CodeRabbit

  • 새 기능
    • 이력서·자기소개서 업로드를 위한 Presigned URL 발급, 업로드 완료 확인, 파일 목록 조회, 삭제 API를 추가했습니다.
    • 파일 분류(이력서/자기소개서)와 허용 포맷(PDF/DOCX/HWP/HWPX)을 기준으로 업로드를 처리합니다.
  • 개선
    • 업로드 형식 불일치, 객체 미존재, 용량 초과, 파일 미존재 등 상황별 응답 코드를 세분화했습니다.
    • S3 버킷/리전 및 Presigned URL 만료 시간을 설정으로 관리할 수 있습니다.
  • 기타
    • 관련 동작을 검증하는 테스트를 추가하고, macOS .DS_Store를 무시하도록 구성했습니다.

@yukyoungs yukyoungs self-assigned this Jul 21, 2026
@yukyoungs yukyoungs added the ✨ Feat 새로운 기능 추가 label Jul 21, 2026
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

S3 presigned URL 기반 이력서·자소서 파일 업로드 기능을 추가했습니다. 파일 형식·카테고리 모델, 업로드 확인·조회·삭제 서비스, API 엔드포인트와 AWS S3 설정을 구현했습니다.

Changes

이력서 파일 관리

Layer / File(s) Summary
S3 실행 환경 설정
.gitignore, build.gradle, src/main/java/com/leets7th/job_is_be/global/..., src/main/resources/application.yml
AWS SDK와 S3 의존성, S3 클라이언트·프리사이너 빈, 환경변수 기반 S3 설정을 추가했습니다.
파일 도메인과 API 계약
src/main/java/com/leets7th/job_is_be/domain/user/enums/*, .../entity/Resume.java, .../repository/ResumeRepository.java, .../dto/*, src/main/java/com/leets7th/job_is_be/global/status/*
파일 카테고리·형식, 사용자별 카테고리 단일 슬롯을 반영한 엔터티·저장소, 요청·응답 DTO와 성공·오류 상태를 정의했습니다.
S3 업로드 및 저장 서비스
src/main/java/com/leets7th/job_is_be/domain/user/service/ResumeService.java, src/test/java/com/leets7th/job_is_be/domain/user/service/ResumeServiceTest.java
presigned URL 발급, 객체 존재·용량 검증, Resume 생성·갱신·조회·삭제 흐름과 주요 예외 처리를 구현하고 테스트했습니다.
파일 관리 HTTP 엔드포인트
src/main/java/com/leets7th/job_is_be/domain/user/controller/ResumeController.java
JWT 사용자 인증을 기반으로 presigned URL 발급, 업로드 확인, 목록 조회, 파일 삭제 API를 연결했습니다.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ResumeController
  participant ResumeService
  participant S3Client
  participant ResumeRepository
  Client->>ResumeController: presigned URL 요청
  ResumeController->>ResumeService: 사용자 ID와 요청 전달
  ResumeService->>S3Client: PUT URL 생성
  S3Client-->>ResumeService: presigned URL 반환
  ResumeService-->>ResumeController: URL과 objectKey 반환
  Client->>S3Client: 파일 업로드
  Client->>ResumeController: 업로드 확인 요청
  ResumeController->>ResumeService: objectKey와 파일 메타데이터 전달
  ResumeService->>S3Client: HeadObject로 파일 검증
  ResumeService->>ResumeRepository: Resume 생성 또는 갱신
  ResumeRepository-->>ResumeService: fileId 반환
  ResumeService-->>ResumeController: 업로드 확인 응답
Loading

Possibly related PRs

  • Leets-Official/Job-is-BE#11: 동일한 ErrorStatusSuccessStatus enum 영역에 기능별 상태 코드를 추가한 변경입니다.

Suggested reviewers: sky-0131

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning .gitignore.DS_Store 무시 항목이 추가되어, 링크된 기능 요구와 무관한 변경이 포함되었습니다. .gitignore.DS_Store 추가가 의도된 변경이 아니라면 제거하고, 기능 구현 관련 변경만 남기세요.
Docstring Coverage ⚠️ Warning Docstring coverage is 2.63% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 이력서/자소서 Presigned URL 업로드 기능 구현이라는 주요 변경점을 정확히 요약합니다.
Linked Issues check ✅ Passed [#30] Presigned URL 발급, 목록 조회, confirm 저장/갱신, 삭제, 1슬롯 유지, 확장자·용량 검증과 예외 처리가 구현되었습니다.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
src/main/resources/application.yml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (2)
src/main/java/com/leets7th/job_is_be/domain/user/entity/Resume.java (1)

43-45: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

컬럼명과 필드명 불일치.

fileFormat 필드가 file_type 컬럼에 매핑되어 있습니다. category(→category), fileName(→file_name), s3Key(→s3_key), uploadedAt(→uploaded_at)은 모두 필드명과 컬럼명이 일치하는데 fileFormat만 예외적입니다. 이전 fileType 컬럼을 재사용한 흔적으로 보이며, 스키마를 직접 조회하는 사람에게 혼란을 줄 수 있습니다.

♻️ 제안
     `@Enumerated`(EnumType.STRING)
-    `@Column`(name = "file_type", nullable = false, length = 10)
+    `@Column`(name = "file_format", nullable = false, length = 10)
     private ResumeFileFormat fileFormat;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/leets7th/job_is_be/domain/user/entity/Resume.java` around
lines 43 - 45, Update the `@Column` mapping on Resume.fileFormat so its column
name matches the field name convention, replacing the legacy file_type name with
file_format. Keep the enum mapping and other column attributes unchanged.
src/main/java/com/leets7th/job_is_be/domain/user/service/ResumeService.java (1)

82-114: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

동시 요청 시 unique 제약 위반으로 500 발생 가능.

findByUserAndCategory 조회와 save/replace 사이에 TOCTOU 윈도우가 있어, 동일 user+category에 대해 동시에 두 요청이 들어오면 (user_id, category) unique 제약을 위반하는 DataIntegrityViolationException이 그대로 전파되어 클라이언트에 일반화되지 않은 500 오류가 노출됩니다. 흔한 시나리오는 아니지만, 잡아서 GeneralException으로 변환하거나 재조회 후 재시도하는 처리가 있으면 더 견고합니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/leets7th/job_is_be/domain/user/service/ResumeService.java`
around lines 82 - 114, Update confirmUpload around findByUserAndCategory and
resumeRepository.save to handle concurrent insert races: catch
DataIntegrityViolationException caused by the user/category unique constraint,
then re-fetch the existing resume and apply the upload update or translate the
conflict to the appropriate GeneralException. Ensure the unique-constraint
violation is not propagated as an unhandled 500 response.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/com/leets7th/job_is_be/domain/user/service/ResumeService.java`:
- Around line 124-132: Update deleteFile so resumeRepository.delete(resume) is
executed before deleteObject(resume.getS3Key()). Preserve the existing
user/resume validation, and perform S3 deletion only after the database deletion
is successfully committed, using the existing cleanup mechanism if the object
deletion fails.
- Around line 58-80: Update issuePresignedUrl and parseFileFormat so the file
extension determines the allowed MIME type on the server. Validate or map the
extension to its corresponding MIME type, reject unsupported or mismatched
request.contentType values, and pass the server-derived MIME type to
PutObjectRequest.contentType instead of the client-supplied value.

In `@src/main/java/com/leets7th/job_is_be/global/status/SuccessStatus.java`:
- Around line 41-44: Update the resume upload confirmation flow using
RESUME_UPLOAD_CONFIRM_SUCCESS so re-uploads that update an existing Resume
record do not return 201 CREATED; distinguish create versus update and select
the appropriate status, or consistently use 200 OK if the operation is an
upsert.

In `@src/main/resources/application.yml`:
- Around line 34-38: S3 설정을 fail-fast 검증으로 변경하세요.
src/main/resources/application.yml 34-38의 AWS_S3_BUCKET 기본값을 제거하고,
src/main/java/com/leets7th/job_is_be/global/properties/AwsS3Properties.java
7-11의 AwsS3Properties에 `@Validated를` 적용한 뒤 bucket에는 `@NotBlank`,
presigned-url-expiration에는 `@Positive` 검증을 추가하세요.

---

Nitpick comments:
In `@src/main/java/com/leets7th/job_is_be/domain/user/entity/Resume.java`:
- Around line 43-45: Update the `@Column` mapping on Resume.fileFormat so its
column name matches the field name convention, replacing the legacy file_type
name with file_format. Keep the enum mapping and other column attributes
unchanged.

In `@src/main/java/com/leets7th/job_is_be/domain/user/service/ResumeService.java`:
- Around line 82-114: Update confirmUpload around findByUserAndCategory and
resumeRepository.save to handle concurrent insert races: catch
DataIntegrityViolationException caused by the user/category unique constraint,
then re-fetch the existing resume and apply the upload update or translate the
conflict to the appropriate GeneralException. Ensure the unique-constraint
violation is not propagated as an unhandled 500 response.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ceef3626-b830-4025-9cfc-c5b12a92c564

📥 Commits

Reviewing files that changed from the base of the PR and between 6f586f0 and 3e9d3c7.

📒 Files selected for processing (18)
  • .gitignore
  • build.gradle
  • src/main/java/com/leets7th/job_is_be/domain/user/controller/ResumeController.java
  • src/main/java/com/leets7th/job_is_be/domain/user/dto/PresignedUrlRequest.java
  • src/main/java/com/leets7th/job_is_be/domain/user/dto/PresignedUrlResponse.java
  • src/main/java/com/leets7th/job_is_be/domain/user/dto/ResumeConfirmRequest.java
  • src/main/java/com/leets7th/job_is_be/domain/user/dto/ResumeResponse.java
  • src/main/java/com/leets7th/job_is_be/domain/user/dto/ResumeUploadResponse.java
  • src/main/java/com/leets7th/job_is_be/domain/user/entity/Resume.java
  • src/main/java/com/leets7th/job_is_be/domain/user/enums/ResumeCategory.java
  • src/main/java/com/leets7th/job_is_be/domain/user/enums/ResumeFileFormat.java
  • src/main/java/com/leets7th/job_is_be/domain/user/repository/ResumeRepository.java
  • src/main/java/com/leets7th/job_is_be/domain/user/service/ResumeService.java
  • src/main/java/com/leets7th/job_is_be/global/config/S3Config.java
  • src/main/java/com/leets7th/job_is_be/global/properties/AwsS3Properties.java
  • src/main/java/com/leets7th/job_is_be/global/status/ErrorStatus.java
  • src/main/java/com/leets7th/job_is_be/global/status/SuccessStatus.java
  • src/main/resources/application.yml

Comment on lines +41 to +44
RESUME_PRESIGNED_URL_SUCCESS(HttpStatus.OK, "RESUME_200_1", "업로드용 Presigned URL을 발급했습니다."),
RESUME_UPLOAD_CONFIRM_SUCCESS(HttpStatus.CREATED, "RESUME_201_1", "이력서/자소서 파일을 저장했습니다."),
RESUME_LIST_SUCCESS(HttpStatus.OK, "RESUME_200_2", "이력서/자소서 파일 목록을 조회했습니다."),
RESUME_DELETE_SUCCESS(HttpStatus.OK, "RESUME_200_3", "이력서/자소서 파일을 삭제했습니다.");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

재업로드 시 201을 반환하는 계약을 수정하세요.

동일 카테고리 재업로드는 기존 Resume 레코드 갱신이지만, 컨트롤러는 항상 RESUME_UPLOAD_CONFIRM_SUCCESS를 사용해 201 CREATED를 반환합니다. 생성과 갱신을 구분해 상태 코드를 선택하거나, upsert API라면 200 OK를 일관되게 사용하세요.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/leets7th/job_is_be/global/status/SuccessStatus.java` around
lines 41 - 44, Update the resume upload confirmation flow using
RESUME_UPLOAD_CONFIRM_SUCCESS so re-uploads that update an existing Resume
record do not return 201 CREATED; distinguish create versus update and select
the appropriate status, or consistently use 200 OK if the operation is an
upsert.

Comment thread src/main/resources/application.yml

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/test/java/com/leets7th/job_is_be/domain/user/service/ResumeServiceTest.java (1)

81-91: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Presigned 요청 구성도 검증하세요.

현재 반환값만 확인하므로 잘못된 bucket, key, Content-Type 또는 만료 시간이 PutObjectPresignRequest에 전달돼도 테스트가 통과합니다. 인자를 캡처해 설정값을 검증하세요.

제안
+import org.mockito.ArgumentCaptor;
+
 ...
         assertThat(response.expiresIn()).isEqualTo(300L);
+
+        ArgumentCaptor<PutObjectPresignRequest> captor =
+                ArgumentCaptor.forClass(PutObjectPresignRequest.class);
+        verify(s3Presigner).presignPutObject(captor.capture());
+
+        PutObjectPresignRequest actual = captor.getValue();
+        assertThat(actual.putObjectRequest().bucket()).isEqualTo("test-bucket");
+        assertThat(actual.putObjectRequest().key()).isEqualTo("profile/1/RESUME");
+        assertThat(actual.putObjectRequest().contentType()).isEqualTo("application/pdf");
+        assertThat(actual.signatureDuration()).isEqualTo(Duration.ofMinutes(5));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/com/leets7th/job_is_be/domain/user/service/ResumeServiceTest.java`
around lines 81 - 91, Update the issuePresignedUrl test around
resumeService.issuePresignedUrl to capture the PutObjectPresignRequest passed to
s3Presigner.presignPutObject, then assert its bucket, object key, content type,
and expiration settings match the expected values. Keep the existing response
assertions unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@src/test/java/com/leets7th/job_is_be/domain/user/service/ResumeServiceTest.java`:
- Around line 81-91: Update the issuePresignedUrl test around
resumeService.issuePresignedUrl to capture the PutObjectPresignRequest passed to
s3Presigner.presignPutObject, then assert its bucket, object key, content type,
and expiration settings match the expected values. Keep the existing response
assertions unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ea76a025-5d95-4403-a693-c3341939da57

📥 Commits

Reviewing files that changed from the base of the PR and between 3e9d3c7 and 53f5121.

📒 Files selected for processing (1)
  • src/test/java/com/leets7th/job_is_be/domain/user/service/ResumeServiceTest.java

jihoonkim501
jihoonkim501 previously approved these changes Jul 21, 2026

@jihoonkim501 jihoonkim501 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

수고 많으셨습니다~! 코드레빗 수정사항만 수정 부탁드릴게요~!~!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/leets7th/job_is_be/domain/user/service/ResumeService.java (1)

102-119: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

S3/DB 일관성 보상 및 재시도 경로를 추가하세요.

confirmUpload()에서 DB save/update 실패 시 이미 업로드된 S3 객체가 유지되면 재확인·재업로드 경로가 없어 orphan이 남을 수 있습니다. deleteFile()afterCommit/deleteObject 실패도 DB 삭제만 적용되고 객체가 남으므로, DELETE를 재시도하거나 Durable outbox로 cleanup 상태를 기록해 복구할 수 있도록 보상해야 합니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/leets7th/job_is_be/domain/user/service/ResumeService.java`
around lines 102 - 119, confirmUpload()에서 DB 저장·수정 실패 시 이미 업로드된 S3 객체를 정리하고
재확인·재업로드할 수 있도록 보상 및 재시도 경로를 추가하세요. deleteFile()의 afterCommit 및 deleteObject 실패도
삭제 상태를 유실하지 않도록 DELETE 재시도 또는 Durable outbox에 cleanup 작업을 기록해 복구 가능하게 하세요. DB와
S3 작업 결과가 어느 한쪽에만 남지 않도록 기존 성공 흐름은 유지하세요.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/com/leets7th/job_is_be/domain/user/service/ResumeService.java`:
- Around line 63-68: Update issuePresignedUrl() so each upload session generates
and persists a unique, non-reusable identifier instead of using only userId and
category in buildObjectKey(). Update confirmUpload() to validate that the
requested object belongs to the active upload session and matches its stored
nonce or verifiable ETag before confirming it, preventing stale objects or
overwritten files from being accepted.

---

Outside diff comments:
In `@src/main/java/com/leets7th/job_is_be/domain/user/service/ResumeService.java`:
- Around line 102-119: confirmUpload()에서 DB 저장·수정 실패 시 이미 업로드된 S3 객체를 정리하고
재확인·재업로드할 수 있도록 보상 및 재시도 경로를 추가하세요. deleteFile()의 afterCommit 및 deleteObject 실패도
삭제 상태를 유실하지 않도록 DELETE 재시도 또는 Durable outbox에 cleanup 작업을 기록해 복구 가능하게 하세요. DB와
S3 작업 결과가 어느 한쪽에만 남지 않도록 기존 성공 흐름은 유지하세요.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 170bf1cc-0ecb-4aa9-a67b-7171d82e72b3

📥 Commits

Reviewing files that changed from the base of the PR and between 53f5121 and 13030a6.

📒 Files selected for processing (11)
  • src/main/java/com/leets7th/job_is_be/domain/user/controller/ResumeController.java
  • src/main/java/com/leets7th/job_is_be/domain/user/dto/PresignedUrlRequest.java
  • src/main/java/com/leets7th/job_is_be/domain/user/dto/ResumeUploadResponse.java
  • src/main/java/com/leets7th/job_is_be/domain/user/entity/Resume.java
  • src/main/java/com/leets7th/job_is_be/domain/user/enums/ResumeFileFormat.java
  • src/main/java/com/leets7th/job_is_be/domain/user/service/ResumeService.java
  • src/main/java/com/leets7th/job_is_be/global/properties/AwsS3Properties.java
  • src/main/java/com/leets7th/job_is_be/global/status/ErrorStatus.java
  • src/main/java/com/leets7th/job_is_be/global/status/SuccessStatus.java
  • src/main/resources/application.yml
  • src/test/java/com/leets7th/job_is_be/domain/user/service/ResumeServiceTest.java
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/main/java/com/leets7th/job_is_be/domain/user/dto/ResumeUploadResponse.java
  • src/main/java/com/leets7th/job_is_be/domain/user/enums/ResumeFileFormat.java
  • src/main/java/com/leets7th/job_is_be/global/properties/AwsS3Properties.java
  • src/main/java/com/leets7th/job_is_be/global/status/ErrorStatus.java
  • src/main/java/com/leets7th/job_is_be/domain/user/controller/ResumeController.java
  • src/test/java/com/leets7th/job_is_be/domain/user/service/ResumeServiceTest.java
  • src/main/java/com/leets7th/job_is_be/domain/user/entity/Resume.java

Comment on lines +63 to +68
String objectKey = buildObjectKey(userId, request.category());

PutObjectRequest objectRequest = PutObjectRequest.builder()
.bucket(awsS3Properties.bucket())
.key(objectKey)
.contentType(fileFormat.mimeType()) // 클라이언트 값 대신 확장자 기준 서버 매핑 MIME 사용

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Files matching ResumeService.java:"
fd -a 'ResumeService\.java$' . || true

file="$(fd 'ResumeService\.java$' . | head -n 1 || true)"
if [ -z "${file:-}" ]; then
  echo "ResumeService.java not found"
  exit 0
fi

echo "Selected: $file"
wc -l "$file"
echo "--- outline ---"
ast-grep outline "$file" --view expanded || true
echo "--- lines 1-180 ---"
sed -n '1,180p' "$file" | nl -ba

Repository: Leets-Official/Job-is-BE

Length of output: 1152


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="./src/main/java/com/leets7th/job_is_be/domain/user/service/ResumeService.java"

echo "--- lines 1-220 ---"
awk '{printf "%4d  %s\n", NR, $0}' "$file" | sed -n '1,220p'

echo "--- related references ---"
rg -n "issuePresignedUrl|confirmUpload|buildObjectKey|resume_file|ResumeCategory|putObject|presigned|metadata|ETag|nonce|session" "${file}" . --glob '!**/build/**' --glob '!**/target/**' --glob '!**/node_modules/**' || true

Repository: Leets-Official/Job-is-BE

Length of output: 50381


🏁 Script executed:

#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
import re

service = Path("./src/main/java/com/leets7th/job_is_be/domain/user/service/ResumeService.java")
text = service.read_text()

keys = {
    "build_fixed_object_key": "buildObjectKey(Long userId, ResumeCategory category)",
    "build_fixed_impl": "buildObjectKey(Long userId, ResumeCategory category) {\n        return \"profile/\" + userId + \"/\" + category.name();",
    "issue_presigned": "public PresignedUrlResponse issuePresignedUrl(Long userId, PresignedUrlRequest request) {",
    "confirm_signature": "public ResumeUploadResponse confirmUpload(Long userId, ResumeConfirmRequest request) {",
    "key_match": "String expectedObjectKey = buildObjectKey(userId, request.category());",
    "no_nonce_field": bool(re.search(r"nonce|presignedSession|sessionId|ETag", text)),
    "metadata_replaced_on_existing": "existing.replace(request.fileName(), fileFormat, uploadedAt);",
    "db_delete_uses_same_key": "String s3Key = resume.getS3Key();\n        resumeRepository.delete(resume);\n",
}
for k, v in keys.items():
    if isinstance(v, bool):
        print(f"{k}: {v}")
    else:
        print(f"{k}: {text.find(v) != -1} at {text.find(v) + 1}")

print("\n--- deterministic flow from source ---")
import ast
class FlowVisitor(ast.NodeVisitor):
    def __init__(self):
        self.in_confirm = False
        self.steps = []
    def visit_FunctionDef(self, node):
        if node.name == "confirmUpload":
            self.in_confirm = True
            for s in node.body:
                self.steps.append((ast.get_source_segment(text, s), s.lineno))
            self.in_confirm = False
        self.generic_visit(node)

print(FlowVisitor().steps)
for stmt, line in FlowVisitor().steps:
    if stmt.strip():
        print(f"line {line}: {stmt.strip()[:220]}")

print("\nAll presignedUrl responses and objectKey usages:")
for p in list(Path(".").rglob("*.java")):
    try:
        data=p.read_text(errors="ignore")
    except Exception:
        continue
    for start,end in [(data.index(s), data.index(s)+len(s)) for s in ["objectKey","presignedUrl","confirmUpload"] if s in data]:
        end=min(len(data), end+120)
        start=max(0, start)
        print(f"{p}:{data.count(chr(10),0,start)+1}: {data[start:start+120].replace(chr(10),' ').strip()}")
PY

Repository: Leets-Official/Job-is-BE

Length of output: 2494


Presigned URL 업로드마다 고유 식별자를 사용하세요.

issuePresignedUrl()에서 objectKeyuser/category로 고정하고 있어 같은 경로가 계속 재사용됩니다. 새 업로드가 실패해도 기존 S3 객체의 headObjectconfirmUpload()가 통과될 수 있고, 기존 파일명이 새 파일명으로 덮어쓰기됩니다. 업로드 세션/nonce 또는 검증 가능한 ETag를 발급/저장해 confirm에서만 해당 세션이 허용하는 업로드를 확정하도록 변경하세요.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/leets7th/job_is_be/domain/user/service/ResumeService.java`
around lines 63 - 68, Update issuePresignedUrl() so each upload session
generates and persists a unique, non-reusable identifier instead of using only
userId and category in buildObjectKey(). Update confirmUpload() to validate that
the requested object belongs to the active upload session and matches its stored
nonce or verifiable ETag before confirming it, preventing stale objects or
overwritten files from being accepted.

@yeonjuncho yeonjuncho left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

승인합니다

@yukyoungs
yukyoungs merged commit 4bf4178 into develop Jul 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feat 새로운 기능 추가

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] 이력서·자소서 파일 업로드/조회/삭제 기능 구현 (S3 Presigned URL)

3 participants