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

feat: 게시글 본문 이미지 업로드/다운로드 기능 추가 #445

Merged

Conversation

gusah009
Copy link
Member

@gusah009 gusah009 commented May 4, 2024

🔥 Related Issue

close: #109

📝 Description

게시글 본문용 이미지 업로드/다운로드 기능 추가

이미지 다운로드는 file hash를 이용하도록 했습니다.

  • mysql에 추가한 컬럼과 sql 쿼리는 아래와 같습니다
ALTER TABLE file ADD file_uuid VARCHAR(50) NULL;
ALTER TABLE file ADD UNIQUE INDEX file_uuid_index (file_uuid);

⭐️ Review Request

@gusah009 gusah009 self-assigned this May 4, 2024
Copy link
Collaborator

@02ggang9 02ggang9 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다~~!!

선배님 덕분에 이슈 2일만에 23에서 6으로 줄였네요!! 감사합니다 감사합니다

@RequestPart MultipartFile file
) {
FileEntity fileEntity = postService.uploadFileForContent(file);
log.info("member \"{}\" uploaded file. memberId: {}, fileId: {}", member.getRealName(), member.getId(),
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
Member Author

Choose a reason for hiding this comment

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

아 보통은 로그를 따로 안남기는데 이 API 같은 경우는 게시글 본문에 이미지를 올리기만 하면 업로드가 되어서 서버 용량에 영향을 미치기가 쉬운 API라 혹시나 모를 어뷰징에 대비해 로그를 남겨놨습니다~

Copy link
Member

@hyuunnn hyuunnn left a comment

Choose a reason for hiding this comment

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

수고하셨습니다... 오랜만에 스프링 코드 보니까 어렵네요

Comment on lines +1044 to +1046
public void 유효한_요청일_경우_게시글_본문_파일_업로드는_성공한다() throws Exception {
String securedValue = getSecuredValue(PostController.class, "uploadFileForContent");

Copy link
Member

Choose a reason for hiding this comment

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

getSecuredValue 아직 쓰이고 있었군요 ㄷㄷ

Comment on lines 89 to 91
.ipAddress(ipAddress)
.fileHash(getRandomUUID())
.build());
Copy link
Member

@hyuunnn hyuunnn May 5, 2024

Choose a reason for hiding this comment

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

fileHash말고 fileUUID는 별로일까요? ㅋㅋ
hash는 일반적으로 MD5, SHA1, SHA256을 생각하게 되는데, 처음부터 uuid라고 명시하면 좋을 것 같아요.

Copy link
Member Author

Choose a reason for hiding this comment

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

fileUUID로 수정해놓겠습니다~

Copy link
Collaborator

@yeochaeeon yeochaeeon left a comment

Choose a reason for hiding this comment

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

수고하셨습니다~!!

@hyuunnn
Copy link
Member

hyuunnn commented May 10, 2024

@gusah009
혹시 CI/CD Failed 뜬 이유 알 수 있을까요?
PR 위에 있는건 passed 되어서요

@gusah009
Copy link
Member Author

@hyuunnn 아마 CI에 사용하는 DB file 테이블에 새로 추가한 file_uuid가 없어서 그런 것 같네요~

@02ggang9 추가해주세요~~ ㅎㅎ dev서버도 DB에 컬럼 추가되면 바로 merge하고 프론트에 알릴게용

@gusah009 gusah009 merged commit bbce420 into develop May 13, 2024
1 check passed
@gusah009 gusah009 deleted the feature/gusah009/#109-게시글-이미지-업로드-기능 branch May 13, 2024 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] 게시글에 이미지 업로드 기능을 구현한다.
4 participants