Skip to content

🔀 :: [#825] - 볼륨 파일 업로드 API 추가 - #826

Merged
dolong2 merged 9 commits into
developfrom
feature/upload-file-api
Aug 9, 2026
Merged

🔀 :: [#825] - 볼륨 파일 업로드 API 추가#826
dolong2 merged 9 commits into
developfrom
feature/upload-file-api

Conversation

@dolong2

@dolong2 dolong2 commented Aug 9, 2026

Copy link
Copy Markdown
Owner

개요

  • 볼륨에 파일을 업로드할 수 있는 API를 추가합니다.

작업내용

  • ByteArray를 받아서 파일을 작성하는 메서드 추가
  • 볼륨의 실제 호스트를 가져오는 메서드 추가
  • 볼륨 파일 업로드 유스케이스 추가
    • 경로 traversal 방지및 파일 저장 실패 관련 예외 분리
    • 상위 디렉토리 자동 생성 여부 옵션 추가
  • 볼륨 파일 업로드 엔드포인트 추가

체크리스트

탬플릿외에 필요한 항목이 있으면 추가해주세요.

  • 로컬에서 빌드가 성공하나요?
  • 추가(수정)한 코드가 정상적으로 동작하나요?
  • pr 타켓 브랜치가 맞게 설정되어 있나요?
  • pr에서 작업할 내용만 작업됐나요?
  • 기존 API와 호환되지 않는 사항이 있나요?

Summary by CodeRabbit

  • 새로운 기능

    • 볼륨에 멀티파트 파일을 업로드하는 API를 추가했습니다.
    • 대상 경로의 안전성을 확인하고 필요 시 상위 디렉터리를 자동으로 생성합니다.
    • 잘못된 경로와 업로드 실패에 대한 명확한 오류 응답을 제공합니다.
    • 업로드 API는 인증된 요청만 사용할 수 있습니다.
  • 버그 수정

    • 빈 파일 업로드를 건너뛰고, 파일 저장 실패를 적절한 오류로 처리합니다.

@dolong2 dolong2 self-assigned this Aug 9, 2026
@dolong2 dolong2 added ✨ Feature 기능 개발 2️⃣ Priority: 중 우선순위 중 labels Aug 9, 2026
@dolong2 dolong2 linked an issue Aug 9, 2026 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@dolong2, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 35 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 60a4d664-0bca-4af5-8b0d-c88de63b4c2b

📥 Commits

Reviewing files that changed from the base of the PR and between 1798bdf and 29e1829.

📒 Files selected for processing (3)
  • src/main/kotlin/com/dcd/server/core/domain/volume/usecase/UploadVolumeFileUseCase.kt
  • src/main/kotlin/com/dcd/server/infrastructure/domain/volume/adapter/DockerVolumeFileStorageAdapter.kt
  • src/main/kotlin/com/dcd/server/infrastructure/global/adapter/FileOperationAdapter.kt

Walkthrough

볼륨 파일 업로드 기능이 추가되었습니다. 경로 검증, Docker 볼륨 경로 확인, 파일 기록, 인증된 HTTP 엔드포인트와 웹 어댑터 테스트가 포함됩니다.

Changes

볼륨 파일 업로드

Layer / File(s) Summary
업로드 계약과 오류 모델
src/main/kotlin/com/dcd/server/core/common/error/ErrorCode.kt, src/main/kotlin/com/dcd/server/core/common/file/spi/FileOperationPort.kt, src/main/kotlin/com/dcd/server/core/domain/volume/exception/*, src/main/kotlin/com/dcd/server/core/domain/volume/spi/VolumeFileStoragePort.kt
볼륨 경로 오류와 업로드 실패 오류 코드가 추가되었습니다. 경로 확인 및 바이트 파일 기록 포트가 정의되었습니다.
경로 확인과 파일 기록
src/main/kotlin/com/dcd/server/core/domain/volume/usecase/UploadVolumeFileUseCase.kt, src/main/kotlin/com/dcd/server/infrastructure/domain/volume/adapter/DockerVolumeFileStorageAdapter.kt, src/main/kotlin/com/dcd/server/infrastructure/global/adapter/FileOperationAdapter.kt
유스케이스가 볼륨 소속, 파일 경로, 디렉터리 조건을 검증합니다. Docker 볼륨의 대상 경로를 확인하고 파일을 기록합니다.
HTTP 엔드포인트와 인증 연결
src/main/kotlin/com/dcd/server/presentation/domain/volume/VolumeWebAdapter.kt, src/main/kotlin/com/dcd/server/infrastructure/global/config/SecurityConfig.kt, src/test/kotlin/com/dcd/server/presentation/domain/volume/VolumeWebAdapterTest.kt
인증된 POST /{workspaceId}/volume/{volumeId}/files 요청을 추가했습니다. 어댑터는 업로드 유스케이스를 호출하고 200 OK를 반환합니다. 테스트는 요청 전달과 응답 상태를 검증합니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant SecurityConfig
  participant VolumeWebAdapter
  participant UploadVolumeFileUseCase
  participant DockerVolumeFileStorageAdapter
  participant FileOperationAdapter
  Client->>SecurityConfig: POST /{workspaceId}/volume/{volumeId}/files
  SecurityConfig->>VolumeWebAdapter: 인증된 멀티파트 요청 전달
  VolumeWebAdapter->>UploadVolumeFileUseCase: execute(volumeId, path, file, createDirectory)
  UploadVolumeFileUseCase->>DockerVolumeFileStorageAdapter: 대상 경로 확인
  DockerVolumeFileStorageAdapter-->>UploadVolumeFileUseCase: Path 반환
  UploadVolumeFileUseCase->>FileOperationAdapter: ByteArray 파일 기록
  FileOperationAdapter-->>UploadVolumeFileUseCase: 기록 완료
  UploadVolumeFileUseCase-->>VolumeWebAdapter: 업로드 완료
  VolumeWebAdapter-->>Client: 200 OK
Loading

Possibly related PRs

  • dolong2/dcd#703: Volume 모델과 볼륨 영속성 포트를 기반으로 볼륨 파일 경로와 업로드를 구현합니다.
  • dolong2/dcd#708: 볼륨 도메인, 오류 코드, VolumeWebAdapter, SecurityConfig를 함께 확장합니다.
  • dolong2/dcd#710: 볼륨 삭제 흐름과 공통 볼륨 웹 계층을 공유합니다.

Poem

당근을 든 토끼가 경로를 확인해요
안전한 볼륨에 파일을 담아요
빈 파일은 조용히 지나가고
새 디렉터리는 필요할 때 자라요
업로드가 끝나면 귀가 쫑긋, 200 OK!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 변경 사항의 핵심인 볼륨 파일 업로드 API 추가를 명확하고 간결하게 설명합니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/upload-file-api

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
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/main/kotlin/com/dcd/server/infrastructure/domain/volume/adapter/DockerVolumeFileStorageAdapter.kt (1)

1-13: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

어댑터를 feature 경로로 이동해야 합니다.

현재 파일은 infrastructure/domain/volume/adapter/에 있습니다. 규칙은 feature 전용 어댑터를 infrastructure/{feature}/adapter/에 두도록 요구합니다. infrastructure/volume/adapter/로 이동하고 패키지 참조를 갱신하세요.

🤖 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/kotlin/com/dcd/server/infrastructure/domain/volume/adapter/DockerVolumeFileStorageAdapter.kt`
around lines 1 - 13, Move DockerVolumeFileStorageAdapter from the domain-nested
infrastructure package to the feature-specific infrastructure/volume/adapter
location, update its package declaration accordingly, and adjust all imports or
references to the adapter while preserving its existing implementation.

Source: Coding guidelines

🤖 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/kotlin/com/dcd/server/core/domain/volume/usecase/UploadVolumeFileUseCase.kt`:
- Around line 35-37: Update the early-return validation in
UploadVolumeFileUseCase so only a missing multipart file part is rejected, while
a present 0-byte file continues through directory creation and is persisted with
writeFileByBytes using an empty byte array. Preserve the existing successful
response behavior for valid files.

In
`@src/main/kotlin/com/dcd/server/infrastructure/domain/volume/adapter/DockerVolumeFileStorageAdapter.kt`:
- Around line 20-32: Update resolveTargetPath to prevent symlink-based volume
escapes, rather than only filtering "." and "..". Validate each existing path
component under resolveVolumeRootPath(volume) with NOFOLLOW_LINKS (or use an
equivalent directory-file-descriptor-based atomic write strategy), and reject
any path resolving outside rootPath before Files.write can follow an internal
symlink.

---

Nitpick comments:
In
`@src/main/kotlin/com/dcd/server/infrastructure/domain/volume/adapter/DockerVolumeFileStorageAdapter.kt`:
- Around line 1-13: Move DockerVolumeFileStorageAdapter from the domain-nested
infrastructure package to the feature-specific infrastructure/volume/adapter
location, update its package declaration accordingly, and adjust all imports or
references to the adapter while preserving its existing implementation.
🪄 Autofix

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 Plus

Run ID: 431ff6cf-6f33-4628-9d1c-4ad46da8e03e

📥 Commits

Reviewing files that changed from the base of the PR and between 54a6810 and 1798bdf.

📒 Files selected for processing (11)
  • src/main/kotlin/com/dcd/server/core/common/error/ErrorCode.kt
  • src/main/kotlin/com/dcd/server/core/common/file/spi/FileOperationPort.kt
  • src/main/kotlin/com/dcd/server/core/domain/volume/exception/InvalidVolumeFilePathException.kt
  • src/main/kotlin/com/dcd/server/core/domain/volume/exception/VolumeUploadFailureException.kt
  • src/main/kotlin/com/dcd/server/core/domain/volume/spi/VolumeFileStoragePort.kt
  • src/main/kotlin/com/dcd/server/core/domain/volume/usecase/UploadVolumeFileUseCase.kt
  • src/main/kotlin/com/dcd/server/infrastructure/domain/volume/adapter/DockerVolumeFileStorageAdapter.kt
  • src/main/kotlin/com/dcd/server/infrastructure/global/adapter/FileOperationAdapter.kt
  • src/main/kotlin/com/dcd/server/infrastructure/global/config/SecurityConfig.kt
  • src/main/kotlin/com/dcd/server/presentation/domain/volume/VolumeWebAdapter.kt
  • src/test/kotlin/com/dcd/server/presentation/domain/volume/VolumeWebAdapterTest.kt

@dolong2
dolong2 merged commit f7b4974 into develop Aug 9, 2026
2 checks passed
@dolong2
dolong2 deleted the feature/upload-file-api branch August 9, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 기능 개발 2️⃣ Priority: 중 우선순위 중

Projects

None yet

Development

Successfully merging this pull request may close these issues.

볼륨 파일 업로드 API 추가

1 participant