diff --git a/src/main/java/com/j9/bestmoments/controller/MyVideoController.java b/src/main/java/com/j9/bestmoments/controller/MyVideoController.java index b5dc5b4..4ce1bc8 100644 --- a/src/main/java/com/j9/bestmoments/controller/MyVideoController.java +++ b/src/main/java/com/j9/bestmoments/controller/MyVideoController.java @@ -67,8 +67,8 @@ public ResponseEntity findById(@PathVariable UUID videoId) { } @Operation(summary = "내 동영상 정보 수정") - @PatchMapping("/{videoId}") - public ResponseEntity update(@PathVariable UUID videoId, @RequestBody @Valid VideoUpdateDto updateDto) { + @PatchMapping(path = "/{videoId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity update(@PathVariable UUID videoId, @ModelAttribute @Valid VideoUpdateDto updateDto) { UUID memberId = UUID.fromString(SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString()); Video video = videoService.findByIdAndUploaderId(videoId, memberId); videoService.update(video, updateDto); diff --git a/src/main/java/com/j9/bestmoments/service/VideoService.java b/src/main/java/com/j9/bestmoments/service/VideoService.java index ca81e94..32eb006 100644 --- a/src/main/java/com/j9/bestmoments/service/VideoService.java +++ b/src/main/java/com/j9/bestmoments/service/VideoService.java @@ -79,6 +79,11 @@ public Video findPublicById(UUID id) { @Transactional public Video update(Video video, VideoUpdateDto updateDto) { + if (updateDto.thumbnail() != null) { + String thumbnailName = FileNameGenerator.generateThumbnailImageFileName(video); + String thumbnailUrl = storageService.uploadFile(updateDto.thumbnail(), thumbnailName); + video.setThumbnailUrl(thumbnailUrl); + } video.setTitle(updateDto.title()); video.setDescription(updateDto.description()); video.setVideoStatus(updateDto.videoStatus());