@@ -41,13 +41,13 @@ public class QuizService {
4141 private final QuizRepository quizRepository ;
4242
4343 @ Transactional
44- public QuizCreateResponse saveQuiz (MultipartFile file , QuizCreateRequest request )
44+ public QuizCreateResponse saveQuiz (MultipartFile thumbnailFile , QuizCreateRequest request )
4545 throws IOException {
4646 String thumbnailPath = defaultThumbnailPath ;
4747
48- if (file != null && !file .isEmpty ()) {
49- validateImageFile (file );
50- thumbnailPath = convertToThumbnailPath (file );
48+ if (thumbnailFile != null && !thumbnailFile .isEmpty ()) {
49+ validateImageFile (thumbnailFile );
50+ thumbnailPath = convertToThumbnailPath (thumbnailFile );
5151 }
5252
5353 // TODO : 시큐리티 구현 이후 삭제 (data.sql로 초기 저장해둔 유저 get), 나중엔 현재 로그인한 유저의 아이디를 받아오도록 수정
@@ -64,26 +64,26 @@ public QuizCreateResponse saveQuiz(MultipartFile file, QuizCreateRequest request
6464 return quizToQuizCreateResponse (savedQuiz );
6565 }
6666
67- private void validateImageFile (MultipartFile file ) {
67+ private void validateImageFile (MultipartFile thumbnailFile ) {
6868
69- if (!file .getContentType ().startsWith ("image" )) {
69+ if (!thumbnailFile .getContentType ().startsWith ("image" )) {
7070 // TODO : 이후 커스텀 예외로 변경
7171 throw new IllegalArgumentException ("이미지 파일을 업로드해주세요." );
7272 }
7373
7474 List <String > allowedExt = List .of ("jpg" , "jpeg" , "png" , "webp" );
75- if (!allowedExt .contains (getExtension (file .getOriginalFilename ()))) {
75+ if (!allowedExt .contains (getExtension (thumbnailFile .getOriginalFilename ()))) {
7676 throw new IllegalArgumentException ("지원하지 않는 확장자입니다." );
7777 }
7878 }
7979
80- private String convertToThumbnailPath (MultipartFile file ) throws IOException {
81- String originalFilename = file .getOriginalFilename ();
80+ private String convertToThumbnailPath (MultipartFile thumbnailFile ) throws IOException {
81+ String originalFilename = thumbnailFile .getOriginalFilename ();
8282 String ext = getExtension (originalFilename );
8383 String savedFilename = UUID .randomUUID ().toString () + "." + ext ;
8484
8585 Path savePath = Paths .get (uploadPath , savedFilename ).toAbsolutePath ();
86- file .transferTo (savePath .toFile ());
86+ thumbnailFile .transferTo (savePath .toFile ());
8787
8888 return "/images/thumbnail/" + savedFilename ;
8989 }
0 commit comments