diff --git a/src/main/java/com/j9/bestmoments/service/VideoService.java b/src/main/java/com/j9/bestmoments/service/VideoService.java index 21fb97a..ca81e94 100644 --- a/src/main/java/com/j9/bestmoments/service/VideoService.java +++ b/src/main/java/com/j9/bestmoments/service/VideoService.java @@ -35,9 +35,15 @@ public Video upload(Member member, VideoCreateDto createDto) { .title(createDto.title()) .description(createDto.description()) .build(); + String videoName = FileNameGenerator.generateVideoFileName(video); String videoUrl = storageService.uploadFile(createDto.video(), videoName); video.setVideoUrl(videoUrl); + + String thumbnailName = FileNameGenerator.generateThumbnailImageFileName(video); + String thumbnailUrl = storageService.uploadFile(createDto.thumbnail(), thumbnailName); + video.setThumbnailUrl(thumbnailUrl); + videoRepository.save(video); return video; } diff --git a/src/main/java/com/j9/bestmoments/util/FileNameGenerator.java b/src/main/java/com/j9/bestmoments/util/FileNameGenerator.java index 2d8a749..be75351 100644 --- a/src/main/java/com/j9/bestmoments/util/FileNameGenerator.java +++ b/src/main/java/com/j9/bestmoments/util/FileNameGenerator.java @@ -18,6 +18,12 @@ public static String generateVideoFileName(Video video) { return String.format("video/%s/video-origin", videoId); } + public static String generateThumbnailImageFileName(Video video) { + String videoId = video.getId().toString(); + String dateString = generateDateString(); + return String.format("video/%s/thumbnail-%s", videoId, dateString); + } + private static String generateDateString() { LocalDateTime now = LocalDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");