Skip to content

[FEAT] 이미지 경로 제거 기능 구현#45

Merged
LimdaeIl merged 5 commits intomainfrom
feat/image-path-resize
Dec 9, 2025
Merged

[FEAT] 이미지 경로 제거 기능 구현#45
LimdaeIl merged 5 commits intomainfrom
feat/image-path-resize

Conversation

@LimdaeIl
Copy link
Collaborator

@LimdaeIl LimdaeIl commented Dec 9, 2025

📝 Pull Request

📌 PR 종류

해당하는 항목에 체크해주세요.

  • 기능 추가 (Feature)
  • 버그 수정 (Fix)
  • 문서 수정 (Docs)
  • 코드 리팩터링 (Refactor)
  • 테스트 추가 (Test)
  • 기타 변경 (Chore)

✨ 변경 내용

이미지 경로를 받지 않는 기능을 구현했습니다.
메서드 오버로딩으로 이전 기능을 살리면서, 모든 이미지를 루트에 저장하도록 구현했습니다.

🔍 관련 이슈

🧪 테스트

변경된 기능에 대한 테스트 범위 또는 테스트 결과를 작성해주세요.

  • 유닛 테스트 추가 / 수정
  • 통합 테스트 검증
  • 수동 테스트 완료

🚨 확인해야 할 사항 (Checklist)

PR을 제출하기 전에 아래 항목들을 확인해주세요.

  • 코드 포매팅 완료
  • 불필요한 파일/코드 제거
  • 로직 검증 완료
  • 프로젝트 빌드 성공
  • 린트/정적 분석 통과 (해당 시)

🙋 기타 참고 사항

리뷰어가 참고하면 좋을 만한 추가 설명이 있다면 적어주세요.

Summary by CodeRabbit

릴리스 노트

  • New Features

    • WebP 형식의 이미지 업로드 지원 추가
    • 이미지 크기를 지정하여 업로드할 수 있는 기능 추가
    • 단일 이미지 또는 여러 크기로 동시 업로드 가능
  • Chores

    • 불필요한 코드 정리

✏️ Tip: You can customize this high-level summary in your review settings.

@LimdaeIl LimdaeIl self-assigned this Dec 9, 2025
Copilot AI review requested due to automatic review settings December 9, 2025 11:58
@LimdaeIl LimdaeIl added the ✨enhancement New feature or request label Dec 9, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 9, 2025

Caution

Review failed

The pull request is closed.

워크스루

이미지 업로드 서비스의 디렉토리 기반 키 생성을 제거하고, 새로운 WebP 업로드 메서드를 추가했습니다. 단일 및 다중 크기의 WebP 이미지를 저장하는 기능이 추가되었으며, 디렉토리 유효성 검사 규칙이 완화되었습니다.

변경 사항

응집력 있는 파일 변경 요약
ImageUploadService 리팩토링
src/main/java/team/wego/wegobackend/image/application/service/ImageUploadService.java
디렉토리 기반 키 생성 제거; buildKey(originalFilename, index)buildBaseName() 오버로드 추가; uploadAsWebpWithSize()uploadAsWebpWithSizes() 메서드 추가; 디렉토리 유효성 검사 조건 완화
Import 정리
src/main/java/team/wego/wegobackend/image/presentation/ImageController.java
미사용 java.util.ArrayList import 제거
HTTP 테스트 업데이트
src/test/http/group/create.http
Multipart form-data 경계 구분자 조정; WebP 및 이미지 파일 테스트 케이스 추가

예상 코드 리뷰 노력

🎯 2 (Simple) | ⏱️ ~10 분

  • 주의 깊게 검토할 영역:
    • uploadAsWebpWithSizes() 메서드의 리스트 크기 동등성 검증 로직
    • buildKey() 오버로드 변경이 기존 호출부에 미치는 영향
    • 완화된 validateDir() 검증 규칙이 다른 기능에 미치는 부작용

관련 PR

🐰 루트에 모여 이미지들이 춤을 추고,
경로 없이 크기만 자유로워라,
WebP 형식으로 변신하며 저장하고,
유효성 검사도 한발 물러서니,
간편함과 유연함이 깃들었네! 🎨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/image-path-resize

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 583ee60 and 8d76a18.

📒 Files selected for processing (3)
  • src/main/java/team/wego/wegobackend/image/application/service/ImageUploadService.java (5 hunks)
  • src/main/java/team/wego/wegobackend/image/presentation/ImageController.java (0 hunks)
  • src/test/http/group/create.http (1 hunks)

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

@LimdaeIl LimdaeIl moved this from Backlog to In progress in WeGo-Together Backend Dec 9, 2025
@LimdaeIl LimdaeIl merged commit 9198add into main Dec 9, 2025
4 of 5 checks passed
@LimdaeIl LimdaeIl deleted the feat/image-path-resize branch December 9, 2025 11:59
@github-project-automation github-project-automation bot moved this from In progress to Done in WeGo-Together Backend Dec 9, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements functionality to store images in the root directory without requiring a subdirectory path. The implementation attempts to preserve backward compatibility through method overloading, adding new methods that don't require the dir parameter while keeping existing methods intact.

  • Added overloaded methods uploadAsWebpWithSize and uploadAsWebpWithSizes without dir parameter for root directory uploads
  • Added helper methods buildKey(String, int) and buildBaseName() for generating keys without directory paths
  • Modified HTTP test file to update multipart form boundaries

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
src/test/http/group/create.http Updated multipart form-data boundary separators in HTTP test file (contains syntax errors)
src/main/java/team/wego/wegobackend/image/presentation/ImageController.java Removed unused ArrayList import
src/main/java/team/wego/wegobackend/image/application/service/ImageUploadService.java Added overloaded upload methods for root directory storage, modified existing uploadOriginal method, and partially disabled directory validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Content-Type: multipart/form-data; boundary=boundary

--boundary
--boundary--
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The boundary separator syntax is incorrect. In multipart/form-data, boundary separators should use --boundary (two hyphens at the start), not --boundary-- (which is only used for the final closing boundary). This will cause the HTTP request to fail or be malformed.

Each part should start with --boundary and only the very last line after all parts should be --boundary--.

Copilot uses AI. Check for mistakes.

< ../image/resources/test-webp1.webp
--boundary
--boundary--
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The boundary separator syntax is incorrect. In multipart/form-data, boundary separators should use --boundary (two hyphens at the start), not --boundary-- (which is only used for the final closing boundary). This will cause the HTTP request to fail or be malformed.

Each part should start with --boundary and only the very last line after all parts should be --boundary--.

Copilot uses AI. Check for mistakes.

< ../image/resources/test-webp1.webp
--boundary
--boundary--
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The boundary separator syntax is incorrect. In multipart/form-data, boundary separators should use --boundary (two hyphens at the start), not --boundary-- (which is only used for the final closing boundary). This will cause the HTTP request to fail or be malformed.

Each part should start with --boundary and only the very last line after all parts should be --boundary--.

Copilot uses AI. Check for mistakes.

< ../image/resources/img1.png
--boundary
--boundary--
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The boundary separator syntax is incorrect. In multipart/form-data, boundary separators should use --boundary (two hyphens at the start), not --boundary-- (which is only used for the final closing boundary). This will cause the HTTP request to fail or be malformed.

Each part should start with --boundary and only the very last line after all parts should be --boundary--.

Copilot uses AI. Check for mistakes.
Comment on lines +55 to +56
// String key = buildKey(dir, originalFilename, index);
String key = buildKey(originalFilename, index);
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The uploadOriginal method still validates the dir parameter (line 49) and accepts it as an argument, but then ignores it when building the key (line 56), using the overloaded buildKey(originalFilename, index) method instead. This creates inconsistent behavior where:

  1. The method still enforces directory validation rules
  2. But the validated directory is never used

This breaks the existing API contract. Since GroupImageService at line 68-74 still calls uploadAsWebpWithSizes(dir, file, i, widths, heights) with a directory path, and the PR description states method overloading should "preserve existing functionality", this implementation is incorrect.

Either:

  • Create a new overloaded method uploadOriginal(MultipartFile file, int index) without the dir parameter for the new behavior
  • Or update all callers to use the new API
Suggested change
// String key = buildKey(dir, originalFilename, index);
String key = buildKey(originalFilename, index);
String key = buildKey(dir, originalFilename, index);

Copilot uses AI. Check for mistakes.

String originalFilename = file.getOriginalFilename();
String key = buildKey(dir, originalFilename, index);
// String key = buildKey(dir, originalFilename, index);
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

Commented-out code should be removed rather than left in the codebase. If this code is needed for reference, it should be documented in a TODO comment or commit message instead. The PR description mentions implementing the feature with method overloading to preserve previous functionality, so the old implementation can be recovered from git history if needed.

Suggested change
// String key = buildKey(dir, originalFilename, index);

Copilot uses AI. Check for mistakes.
Comment on lines +257 to +264
// TODO: 모임 경로: FE 요청으로 루트 디렉토리로 개선했습니다.
// if (dir == null || dir.isBlank()) {
// throw new ImageException(ImageExceptionCode.DIR_REQUIRED);
// }

// if (!dir.matches("[a-zA-Z0-9_\\-/]+")) {
// throw new ImageException(ImageExceptionCode.DIR_INVALID_PATTERN);
// }
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The validateDir method has most of its validation logic commented out (lines 258-264), but still validates for path traversal (line 266-268) and trailing slashes (line 270-272). This creates an inconsistent state where:

  1. The method is still called by existing methods like uploadAsWebpWithSizes(String dir, ...) at line 132
  2. But it only performs partial validation

This makes the code confusing and error-prone. Consider either:

  • Removing the commented code if directory validation is no longer needed
  • Or creating a separate validation method for the new root-only functionality

The commented-out validation checks are still being called by the existing dir-based methods, so they may cause unexpected behavior.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEAT] 이미지 경로 제거 기능 구현

1 participant

Comments