-
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: 영양사 이미지 압축 다운로드 #1175
base: develop
Are you sure you want to change the base?
feat: 영양사 이미지 압축 다운로드 #1175
Conversation
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.
잘개 쪼개진 커밋 + 함수 덕분에 빠르게 리뷰했습니다.
고생하셨어요~!
// HTTP 응답 헤더 설정 | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); | ||
headers.add("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName); | ||
headers.add("Cache-Control", "no-cache, no-store, must-revalidate"); | ||
headers.add("Pragma", "no-cache"); | ||
headers.add("Expires", "0"); |
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.
브라우저 캐싱을 허용하지 않은 이유가 있나요?
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.
다운로드 구현에 실패할 때 이것저것 시도하면서 들어갔는데 지금 다시 수정해보니 캐싱을 허용해도 잘 동작하네요.
캐싱 적용하겠습니다. 감사합니다!
|
||
private File generateZipFileOf(List<Dining> dinings) { | ||
String bucketName = s3Utils.getBucketName(); | ||
File parentDirectory = new File("image-download", RandomStringUtils.randomAlphanumeric(6)); |
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.
동시성 이슈를 이렇게 해결할 수도 있네요!
(매우 극악의 확률로 동시에 들어온 두 요청의 6자리 id값이 겹친다면..?)
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.
단일 호출에서 동일한 값을 반환할 확률은 1/56,800,235,584 정도라고 합니다.(from. gpt)
이 기능을 사용하는 사용자는 현재로써 동시간에 1명뿐이라 괜찮지 않을까 생각합니다..!
+) 파일명이 겹쳐서 문제가 생기게 된다면 해당 파일명이 존재하는지 점검하는 로직을 추가하여 해소할 수도 있겠네요!
public File generateDiningImageCompress(LocalDate startDate, LocalDate endDate, Boolean isCafeteria) { | ||
validateDates(startDate, endDate); | ||
List<Dining> dining = fetchDiningDataForImageCompress(startDate, endDate, isCafeteria); | ||
return generateZipFileOf(dining); | ||
} |
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.
기능 단위로 쪼개어 두고 무엇을 하는 코드인지 함수명으로 적절하게 명시를 해주어서 로직을 처음 접하는 입장에서도 흐름을 이해하기 편했습니다.
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.
감사합니다!
public void removeDiningImageCompress(File zipFilePath) { | ||
new Thread(() -> remove(zipFilePath.getParentFile())).start(); | ||
} |
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.
잔여 압축 파일 삭제를 비동기 처리하는 디테일.. 배워갑니다
🔥 연관 이슈
🚀 작업 내용
💬 리뷰 중점사항