-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] S3 이미지 업로드 및 삭제 기능 구현 #40
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
이미지 1장을 받아서 S3에 저장하고 저장된 url을 Dto로 반환하는 기능 구현. 파일 업로드 실패시 예외 처리
클라이언트가 url을 JSON으로 보내면 해당 S3에 위치한 이미지 파일 삭제 기능 구현.
이미지 저장시 UUID로 파일명을 고유값으로 만들어서 동일한 이미지가 덮어씌여지지 않도록 함
단순히 S3RequestDto, S3ResponseDto에서 목적어를 추가함으로써 어떤 Dto인지 분명하게 의미를 전달함
S3DeleteRequestDto 삭제. 컨트롤러에서 삭제 요구 url 데이터를 @RequestBody에서 @RequestParam으로 변경함.
junmo95
approved these changes
Jan 8, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
수고하셨습니다! :) |
jo0oy
reviewed
Jan 8, 2024
src/test/resources/application.yml
Outdated
@@ -4,6 +4,8 @@ spring: | |||
datasource: | |||
driver-class-name: org.testcontainers.jdbc.ContainerDatabaseDriver | |||
url: jdbc:tc:mysql:8:///tripcometrue?characterEncoding=UTF-8&serverTimezone=Asia/Seoul | |||
config: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
윗줄에 보시면 이미 설정이 되어 있어서 해당 부분 삭제 하시면 될거 같습니다!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎯 목적
새 기능 (New Feature)
설정 (Setup)
간략한 설명:
: 클라이언트측에서 S3에 이미지를 업로드하고 url을 반환 받거나, 이미지 url을 통해 S3 이미지를 삭제할 수 있는 기능입니다.
🛠 작성 사항
- 이미지 저장 / 수정 / 삭제 흐름
imageUrl
로 삭제할 이미지의 S3 URL을 보냅니다.해당 기능 사용법
발생 예외 항목
FileEmptyException
: 업로드 요청 파일이 없는 경우FileMaxSizeExceededException
: 파일이 허용 용량을 초과할 경우FileNotExistsException
: 삭제 요청한 파일이 S3에 존재하지 않을 경우FileUploadFailException
: 기타 원인으로 S3 업로드에 실패할 경우🔗 관련 이슈
💡 특이 사항 및 고민 지점
- 개발용 버킷과 배포용 버킷을 구분했습니다.
tripcometrue-dev-s3-bucket
입니다.tripcometrue-s3-bucket
입니다.- 버킷 내부에 디렉토리를 나누지 않았습니다.
- 파일을 업로드하면 UUID로 고유의 파일명으로 변환시킨 뒤 S3에 저장합니다.
- 업로드 최대 용량을 5MB로 설정했습니다.
FileMaxSizeExceededException
예외를 발생시킵니다.- 멀티파트 파일을 File 객체로 변환하지 않습니다.
FIle
객체로 변환한 후 S3에 업로드하는 경우가 있습니다.File
객체로 변환시 어떤 이점이 있는지 파악한 뒤에 리팩토링을 진행하겠습니다.- 조금 더 객체지향적인 설계가 가능할 것 같습니다.
기타 의견이 있으시면 말씀 부탁드립니다.