Skip to content
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

[Feature] 파일 S3 업로드 추가, 필터에서 Multipart 데이터를 받기 위한 ServletRequest Wrapping #64

Merged
merged 9 commits into from
Aug 22, 2024

Conversation

eckrin
Copy link
Collaborator

@eckrin eckrin commented Aug 21, 2024

🎯 이슈 번호

Issue #52

💡 작업 내용

  • s3 의존성 추가, 업로드 로직 추가
  • 필터에서 Mdc로 요청 캐싱시 Controller에서 발생하는 읽기 오류 원인 파악
  • ServletRequest를 Wrapping하기 위한 스프링 서블릿 아키텍처 파악
  • inputstream은 한 번밖에 읽지 못하는데, 로깅을 위해서 Wapper객체를 사용하여 서블릿 메서드 오버라이딩
  • 관련 테스트코드 수정

💡 자세한 설명

과정
KakaoTalk_Photo_2024-08-21-22-00-14

-> 정리해서 추가하겠습니다
-> 주석으로 추가했습니다.

image image

-> json과 multipart 잘 들어가고, 로그 잘 남습니다.

image

-> s3 업로드 잘 됩니다.

📗 참고 자료

https://coderanch.com/t/781674/open-source/apache-common-FileUpload
https://stackoverflow.com/questions/68478443/converting-multipartfile-to-file
https://commons.apache.org/proper/commons-fileupload/overview.html
https://stackoverflow.com/questions/48255058/how-to-check-if-httpservletrequest-getpart-is-set-or-not

✅ 셀프 체크리스트

  • PR 제목을 형식에 맞게 작성했나요?
  • 브랜치 전략에 맞는 브랜치에 PR을 올리고 있나요? (master/main이 아닙니다.)
  • Reviewers, Labels, Projects를 등록했나요?
  • 작업 도중 문서 수정이 필요한 경우 잘 수정했나요?
  • 테스트는 잘 통과했나요?
  • 불필요한 코드는 제거했나요?

eckrin added 6 commits August 21, 2024 21:14
- 요청 dto에서 이미지 경로가 아닌 파일 업로드
- 요청 dto에서 이미지 경로가 아닌 파일 업로드
- ServletRequestMapper의 ServletRequest 구현체(Request.class) 메서드 오버라이딩
- content 파싱하여 로깅
@eckrin eckrin self-assigned this Aug 21, 2024
@eckrin eckrin added the enhancement New feature or request label Aug 21, 2024
Comment on lines 13 to 17
/**
* 일반적인 Json Body를 로깅하기 위해서 Mdc에 저장하는 필터
*/
public class RequestMultipartBodyCollectionFilter extends OncePerRequestFilter {

Copy link
Collaborator

Choose a reason for hiding this comment

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

여기부분 주석이 잘못된것 같아요.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

감사합니다 반영했습니다

Comment on lines 181 to 189
outer:
for (int i=start; i<=data.length-pattern.length; i++) {
for (int j=0; j<pattern.length; j++) {
if (data[i+j] != pattern[j])
continue outer;
}
return i;
}
return -1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

와 continue나 break에 라벨을 붙일수도 있군요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

goto를 권장하지 않고있어서 저는 이런식으로 하는데, 더 좋은 방법 알고계시면 알려주시면 감사합니다

Copy link
Collaborator

@luna156 luna156 left a comment

Choose a reason for hiding this comment

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

와 정말 수고하셨습니다. 아주 깔끔한것 같아요. 머지해도 좋을 것 같습니다.

- 주석 추가/수정
- 상수 분리
@eckrin
Copy link
Collaborator Author

eckrin commented Aug 22, 2024

많이 복잡한 작업이었는데 정말 많이 도와주셔서 훨씬 빠르게 할 수 있었던 것 같습니다. 감사합니다

@eckrin eckrin merged commit b8071b2 into master Aug 22, 2024
1 check passed
@eckrin eckrin deleted the feat/admin-image branch August 22, 2024 03:19
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