역할


1. 핵심 구조

@Service
public class FileStorageService {

    private final Path root;

    public FileStorageService(@Value("${app.upload-dir}") String uploadDir) {
        this.root = Paths.get(uploadDir).normalize(); // 절대 경로 변환
    }

    // module 명 검증 및 정리
    private String editorDir(String module) { ... }

    // 임시 tmp 폴더에 에디터 이미지 저장
    public String storeEditorImageToTmp(MultipartFile file, String module) { ... }

    // content에서 tmp 이미지 URL 추출
    public List<String> extractTmpEditorImagePaths(String content, String module) { ... }

    // tmp → owner 폴더로 이동
    public String moveTmpToOwnerDir(String tmpPath, String module, Long ownerId) { ... }

    // content 내 tmp 이미지 이동 + URL 치환
    public String commitEditorImagesInContent(String content, String module, Long ownerId) { ... }

    // 깨진 iframe <a> 태그 정리
    private String normalizeQuillHtml(String html) { ... }

    // /uploads/... → 실제 서버 경로 변환
    public Path resolveUploadPath(String storagePath) { ... }

    // 첨부파일 저장 (task 관련)
    public StoredAttachment storeTaskAttachmentToTaskDir(MultipartFile file, String module, Long taskId) { ... }
}

2. 설명

  1. 에디터 이미지 처리
  2. 첨부파일 처리
  3. 공통 안전장치

3. 포인트