refactor: 영상 처리 방식을 메모리에서 디스크로 전환 #48
Merged
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the video answer submission process to use file paths instead of byte arrays, which improves memory efficiency during file handling. The FileUploader has been simplified by removing unused methods, and VideoAnswerAnalyzer now includes more detailed logging for its asynchronous tasks. Feedback focuses on addressing a potential resource leak where temporary files are not deleted after processing, refining exception handling to be more specific, and ensuring consistent S3 key generation by using the UTC timezone.
| Path videoPath = Files.createTempFile("video-", getExtension(video.getOriginalFilename())); | ||
| Files.write(videoPath, videoBytes); | ||
| log.info("[VIDEO] 영상 답변 처리 시작 - questionId: {}, memberId: {}", questionId, memberId); | ||
| Path videoPath = createTempFile(video); |
There was a problem hiding this comment.
| import io.wisoft.prepair.prepair_api.global.exception.ErrorCode; | ||
| import io.wisoft.prepair.prepair_api.repository.QuestionRepository; | ||
| import java.io.IOException; | ||
|
|
| Path videoPath = Files.createTempFile("video-", getExtension(video.getOriginalFilename())); | ||
| video.transferTo(videoPath); | ||
| return videoPath; | ||
| } catch (Exception e) { |
| String extension = getExtension(originalFilename); | ||
| public String upload(Path videoPath, String contentType, String email) { | ||
| String extension = getExtension(videoPath.getFileName().toString()); | ||
| String key = "interview-video/" + email + "/" + LocalDate.now() + "/" + UUID.randomUUID() + extension; |
There was a problem hiding this comment.
LocalDate.now()는 서버의 시스템 시간대에 의존합니다. 서비스의 일관성을 위해 UTC 시간대를 명시적으로 사용하는 것을 권장합니다.
Suggested change
| String key = "interview-video/" + email + "/" + LocalDate.now() + "/" + UUID.randomUUID() + extension; | |
| String key = "interview-video/" + email + "/" + java.time.LocalDate.now(java.time.ZoneOffset.UTC) + "/" + UUID.randomUUID() + extension; |
This file contains hidden or 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
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.
📌 관련 이슈 (Related Issue)
📝 작업 내용 (Description)
byte[]제거,createTempFile()헬퍼 메서드로 추출VideoAnswerAnalyzer.uploadToS3():byte[]→ Path 파라미터로 변경FileUploader.upload():byte[]→ Path 기반으로 변경,RequestBody.fromFile()사용upload(MultipartFile)오버로드 제거[VIDEO],[VIDEO-S3],[VIDEO-STT],[VIDEO-ANALYSIS]로 통일🔄 변경 유형 (Type of Change)
✅ 체크리스트 (Checklist)
💬 추가 코멘트 (Additional Comments)