Skip to content

Commit

Permalink
시험 지문에 마크다운 에디터로 이미지 추가를 할 수 있다. (#46)
Browse files Browse the repository at this point in the history
* refactor: image original file name null check

* feat: uiw/react-md-editor 의존성 추가

* feat: 클라이언트 시험 지문 이미지 업로드 API 작성

* feat: 시험 지문에 이미지 드래그 앤 드랍 기능 구현

* refactor: 이미지 업로드 시 특정 텍스트를 입력하고, 업로드 완료 시 텍스트 대체

* feat: useUpload custom hook 작성

* feat: tailwind animate-spin을 이용한 Loading spinner 구현

* feat: 이미지 업로드 및 로딩 기능 구현

* refactor: 사용하지 않는 파일 제거

* refactor: click uploader transition color

* feat: markdown viewer 추가

* refactor: 사용하지 않는 import 제거

* refactor: onPaste preventDefault 시 기본 붙여넣기 안되는 문제 해결

* refactor: 사용하지 않는 파라미터 제거
  • Loading branch information
alstn113 committed Feb 2, 2025
1 parent cf17ccc commit ea1a0d1
Show file tree
Hide file tree
Showing 12 changed files with 2,301 additions and 2,500 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.fluffy.exam.domain.ExamImage;
import com.fluffy.exam.domain.ExamImageRepository;
import com.fluffy.exam.domain.ExamRepository;
import com.fluffy.global.exception.BadRequestException;
import com.fluffy.global.exception.ForbiddenException;
import com.fluffy.global.web.Accessor;
import com.fluffy.storage.application.StorageClient;
Expand All @@ -31,7 +32,7 @@ public String uploadImage(Long examId, MultipartFile image, Accessor accessor) {
UUID imageId = UUID.randomUUID();

Long fileSize = image.getSize();
String filePath = generateUploadPath(imageId, accessor.id(), image.getOriginalFilename());
String filePath = generateUploadPath(imageId, accessor.id(), image);

ExamImage examImage = new ExamImage(imageId, accessor.id(), examId, filePath, fileSize);
examImageRepository.save(examImage);
Expand All @@ -53,7 +54,13 @@ private void validateExamAuthor(Long examId, Accessor accessor) {
}
}

private String generateUploadPath(UUID imageId, Long memberId, String originalFilename) {
private String generateUploadPath(UUID imageId, Long memberId, MultipartFile image) {
String originalFilename = image.getOriginalFilename();

if (image.isEmpty() || originalFilename == null) {
throw new BadRequestException("이미지 파일이 비어있습니다.");
}

int lastDotIndex = originalFilename.lastIndexOf(".");
String extension = originalFilename.substring(lastDotIndex + 1);

Expand Down
2 changes: 2 additions & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@hello-pangea/dnd": "^17.0.0",
"@nextui-org/react": "^2.4.8",
"@tanstack/react-query": "^5.59.16",
"@uiw/react-md-editor": "^4.0.5",
"axios": "^1.7.7",
"date-fns": "^4.1.0",
"framer-motion": "^11.13.1",
Expand All @@ -25,6 +26,7 @@
"react-hot-toast": "^2.4.1",
"react-icons": "^5.4.0",
"react-router": "^7.0.2",
"rehype-sanitize": "^6.0.0",
"zustand": "^5.0.0"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit ea1a0d1

Please sign in to comment.