March 22, 2023


<aside> <img src="/icons/list_gray.svg" alt="/icons/list_gray.svg" width="40px" /> 목차

</aside>

문제

TOAST 에디터 hooks 함수

컨트롤러

@Controller
@RequiredArgsConstructor
@RequestMapping("/files")
public class FileController {

		...
	
		@ResponseBody
		@GetMapping("/images/{storedFileName}")
		public Resource downloadImage(
		        @PathVariable String storedFileName
		) throws MalformedURLException {
		    return new UrlResource("file:" + filePath + storedFileName);
		}
		
		@ResponseBody
		@PostMapping("/images/new")
		public String uploadImage(
		        @RequestParam("image") MultipartFile multipartFile
		) throws IOException {
		    
		    if (multipartFile.isEmpty()) {
		        return "not found";
		    }
		
		    UploadFile uploadFile = fileManager.storeFile(multipartFile);
		    String storedFileName = uploadFile.getStoredFileName();
		
		    return "/files/images/" + storedFileName;
		}
	
		...
}

References