Skip to content

Commit

Permalink
rename: 파일명 생성기 패키지 및 이름 변경
Browse files Browse the repository at this point in the history
`/util/fileNameGenerator` -> `/service/fileNameProvider`
  • Loading branch information
SJ70 committed Oct 2, 2024
1 parent a9ea37f commit 9baac40
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.j9.bestmoments.util;
package com.j9.bestmoments.service;

import com.j9.bestmoments.domain.Member;
import com.j9.bestmoments.domain.Video;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import org.springframework.web.multipart.MultipartFile;

public final class FileNameGenerator {
public final class FileNameProvider {

public static String generateProfileImageFileName(Member member, MultipartFile file) {
String memberId = member.getId().toString();
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/j9/bestmoments/service/MemberService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import com.j9.bestmoments.domain.Member;
import com.j9.bestmoments.repository.MemberRepository;
import com.j9.bestmoments.service.storageService.StorageService;
import com.j9.bestmoments.util.FileNameGenerator;
import jakarta.persistence.EntityNotFoundException;
import java.util.Optional;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
Expand Down Expand Up @@ -68,7 +66,7 @@ public Member update(Member member, MemberUpdateDto memberUpdateDto) {
member.setDescription(memberUpdateDto.description());
}
if (memberUpdateDto.file() != null) {
String fileName = FileNameGenerator.generateProfileImageFileName(member, memberUpdateDto.file());
String fileName = FileNameProvider.generateProfileImageFileName(member, memberUpdateDto.file());
String profileImageUrl = googleCloudStorageService.uploadFile(memberUpdateDto.file(), fileName);
member.setProfileImageUrl(profileImageUrl);
}
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/com/j9/bestmoments/service/VideoService.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.j9.bestmoments.dto.request.VideoUpdateDto;
import com.j9.bestmoments.repository.VideoRepository;
import com.j9.bestmoments.service.storageService.LocalStorageService;
import com.j9.bestmoments.util.FileNameGenerator;
import jakarta.persistence.EntityNotFoundException;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -38,12 +37,12 @@ public Video upload(Member member, VideoCreateDto createDto) {
.build();

// 원본 영상
String originVideoName = FileNameGenerator.generateVideoFileName(video, createDto.video());
String originVideoName = FileNameProvider.generateVideoFileName(video, createDto.video());
String originVideoUrl = storageService.uploadFile(createDto.video(), originVideoName);
video.setVideoUrl(originVideoUrl);

// 썸네일 이미지
String thumbnailName = FileNameGenerator.generateThumbnailImageFileName(video, createDto.thumbnail());
String thumbnailName = FileNameProvider.generateThumbnailImageFileName(video, createDto.thumbnail());
String thumbnailUrl = storageService.uploadFile(createDto.thumbnail(), thumbnailName);
video.setThumbnailUrl(thumbnailUrl);

Expand Down Expand Up @@ -72,7 +71,7 @@ public Video upload(Member member, VideoCreateDto createDto) {
}

private String uploadEncodedVideo(String videoUrl, String resolution) {
String encodedVideoUrl = FileNameGenerator.generateEncodedVideoFileName(videoUrl, resolution);
String encodedVideoUrl = FileNameProvider.generateEncodedVideoFileName(videoUrl, resolution);
ffmpegService.encodeVideo(videoUrl, encodedVideoUrl, resolution);
return encodedVideoUrl;
}
Expand Down Expand Up @@ -109,7 +108,7 @@ public Video findPublicById(UUID id) {
@Transactional
public Video update(Video video, VideoUpdateDto updateDto) {
if (updateDto.thumbnail() != null) {
String thumbnailName = FileNameGenerator.generateThumbnailImageFileName(video, updateDto.thumbnail());
String thumbnailName = FileNameProvider.generateThumbnailImageFileName(video, updateDto.thumbnail());
String thumbnailUrl = storageService.uploadFile(updateDto.thumbnail(), thumbnailName);
video.setThumbnailUrl(thumbnailUrl);
}
Expand Down

0 comments on commit 9baac40

Please sign in to comment.