feat: quiz, lecture 이미지 등록시 파일 형식 확인

This commit is contained in:
kgc91747 2024-08-12 13:40:18 +09:00
parent abcf4b7959
commit a0b363d74f
2 changed files with 16 additions and 0 deletions

View File

@ -36,6 +36,10 @@ public class LectureController {
return new ResponseEntity<>(HttpStatus.CONFLICT);
}
if (!image.isEmpty() && !image.getContentType().startsWith("image")) {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
lectureService.createLecture(userId, lectureCreateRequest, image);
return new ResponseEntity<>(HttpStatus.CREATED);

View File

@ -38,6 +38,12 @@ public class QuizController {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
for (MultipartFile image : images) {
if (!image.isEmpty() && !image.getContentType().startsWith("image")) {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}
QuizSet quizSet = quizSetService.createQuizSet(userId, quizSetCreateRequest.getTitle());
int imageIdx = 0;
@ -81,6 +87,12 @@ public class QuizController {
return new ResponseEntity<>(HttpStatus.CONFLICT);
}
for (MultipartFile image : images) {
if (!image.isEmpty() && !image.getContentType().startsWith("image")) {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}
quizSetService.updateQuizSet(quizSetUpdateRequest.getId(), quizSetUpdateRequest.getTitle());
Map<Long, Boolean> quizUpdatedCheckMap = new HashMap<>();