Skip to content

Conversation

@ekgns33
Copy link
Contributor

@ekgns33 ekgns33 commented May 3, 2025

작업내역

  • S3에 이미지를 서버에서 업로드하는 로직 추가
  • Multipartform으로 요청 변경, param 바인딩 Converter 추가
  • test코드 수정

Summary by CodeRabbit

  • New Features

    • Signup now supports uploading a profile image directly as part of the registration process.
    • File uploads are handled securely and stored in AWS S3, with automatic URL generation for uploaded files.
  • Bug Fixes

    • Improved error handling for file upload failures, with clear messages for users.
  • Chores

    • Updated configuration to support multipart file uploads and set file size limits.
    • Enhanced test cases to reflect the new signup and file upload flow.

@ekgns33 ekgns33 added the enhancement New feature or request label May 3, 2025
@ekgns33 ekgns33 self-assigned this May 3, 2025
@coderabbitai
Copy link

coderabbitai bot commented May 3, 2025

Walkthrough

This set of changes introduces multipart file upload support for user signup, enabling users to upload a profile image during registration. The signup API endpoint is updated to accept multipart/form-data, with the profile image sent as a file and other data as a JSON string parameter. Supporting changes include a new converter for deserializing JSON strings to request objects, a new file storage service for handling uploads to AWS S3, and updates to S3 integration for direct file uploads. Related configuration, enums, and tests are also updated to accommodate and validate the new file upload functionality.

Changes

File(s) Change Summary
src/main/java/org/runimo/runimo/auth/controller/AuthController.java Modified the signup endpoint to accept multipart/form-data with a profile image file and updated method signature accordingly.
src/main/java/org/runimo/runimo/auth/controller/request/AuthSignupConverter.java Added a new converter class to deserialize JSON strings into AuthSignupRequest objects for multipart requests.
src/main/java/org/runimo/runimo/auth/controller/request/AuthSignupRequest.java Removed the imgUrl field, updated the command conversion method to accept a file parameter instead of an image URL.
src/main/java/org/runimo/runimo/auth/service/SignUpUsecaseImpl.java Added dependency on FileStorageService and updated user registration to upload and retrieve the profile image URL.
src/main/java/org/runimo/runimo/auth/service/dto/UserSignupCommand.java Changed the profile image field from a URL string to a MultipartFile object.
src/main/java/org/runimo/runimo/config/S3Config.java Added a new bean for S3Client to enable direct S3 file uploads.
src/main/java/org/runimo/runimo/config/WebMvcConfig.java Registered the new AuthSignupConverter in the Spring MVC formatter registry.
src/main/java/org/runimo/runimo/external/ExternalResponseCode.java Added a new enum constant for file upload failure error handling.
src/main/java/org/runimo/runimo/external/FileStorageService.java Introduced a new service for file storage operations, including upload and presigned URL generation.
src/main/java/org/runimo/runimo/external/ImageUploadController.java Switched dependency from S3Service to FileStorageService for presigned URL generation.
src/main/java/org/runimo/runimo/external/S3Service.java Added direct file upload method using S3Client, improved error handling, and centralized object key generation.
src/main/java/org/runimo/runimo/user/domain/Gender.java Updated the Gender enum to implement Serializable.
src/main/resources/application.yml Added multipart file upload configuration with size limits.
src/test/java/org/runimo/runimo/auth/controller/AuthControllerTest.java Updated signup test to use multipart requests and removed image URL from the payload.
src/test/java/org/runimo/runimo/rewards/RewardTest.java Changed a test setup argument from a string to null for the signup command.
src/test/java/org/runimo/runimo/user/api/UserItemAcceptanceTest.java Updated user signup test to use multipart form-data and removed image URL from the request.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant AuthController
    participant AuthSignupConverter
    participant FileStorageService
    participant S3Service
    participant SignUpUsecaseImpl

    Client->>AuthController: POST /signup (multipart/form-data: request, profileImage)
    AuthController->>AuthSignupConverter: Convert request (JSON String) to AuthSignupRequest
    AuthController->>SignUpUsecaseImpl: signupAndLogin(AuthSignupRequest, profileImage)
    SignUpUsecaseImpl->>FileStorageService: storeFile(profileImage)
    FileStorageService->>S3Service: uploadFile(profileImage)
    S3Service-->>FileStorageService: file URL
    FileStorageService-->>SignUpUsecaseImpl: file URL
    SignUpUsecaseImpl-->>AuthController: SignupUserResponse
    AuthController-->>Client: SuccessResponse<SignupUserResponse>
Loading

Poem

🐇
Multipart forms now hop in with glee,
Profile images upload as easy as can be!
S3 buckets await, new URLs are spun,
With converters and beans, the work is well done.
Tests and configs join the fun,
As rabbits rejoice—file upload has begun!
☁️📸


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between 80a9e76 and 7d03f0d.

📒 Files selected for processing (16)
  • src/main/java/org/runimo/runimo/auth/controller/AuthController.java (2 hunks)
  • src/main/java/org/runimo/runimo/auth/controller/request/AuthSignupConverter.java (1 hunks)
  • src/main/java/org/runimo/runimo/auth/controller/request/AuthSignupRequest.java (2 hunks)
  • src/main/java/org/runimo/runimo/auth/service/SignUpUsecaseImpl.java (3 hunks)
  • src/main/java/org/runimo/runimo/auth/service/dto/UserSignupCommand.java (1 hunks)
  • src/main/java/org/runimo/runimo/config/S3Config.java (2 hunks)
  • src/main/java/org/runimo/runimo/config/WebMvcConfig.java (2 hunks)
  • src/main/java/org/runimo/runimo/external/ExternalResponseCode.java (1 hunks)
  • src/main/java/org/runimo/runimo/external/FileStorageService.java (1 hunks)
  • src/main/java/org/runimo/runimo/external/ImageUploadController.java (2 hunks)
  • src/main/java/org/runimo/runimo/external/S3Service.java (3 hunks)
  • src/main/java/org/runimo/runimo/user/domain/Gender.java (1 hunks)
  • src/main/resources/application.yml (1 hunks)
  • src/test/java/org/runimo/runimo/auth/controller/AuthControllerTest.java (2 hunks)
  • src/test/java/org/runimo/runimo/rewards/RewardTest.java (1 hunks)
  • src/test/java/org/runimo/runimo/user/api/UserItemAcceptanceTest.java (1 hunks)

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Join our Discord community for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ekgns33 ekgns33 merged commit f8f7be3 into main May 3, 2025
3 checks passed
@ekgns33 ekgns33 deleted the feat/upload-image-when-signup branch May 3, 2025 09:18
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

None yet

Development

Successfully merging this pull request may close these issues.

2 participants