天天看點

關于使用editor_md支援markdown元件以及其中的圖檔上傳功能

關于使用editor_md支援markdown元件以及其中的圖檔上傳功能

後端參數接收

@ResponseBody
@PostMapping(value = "/uploadFiles")
public Map<String, Object> uploadFiles(@RequestParam("editormd-image-file") MultipartFile file) {

    Map<String, Object> result = new HashMap<>();
    String fileUrl = ossService.uploadFile(file, "imgs");
    log.info("fileUrl=>"+fileUrl);
    result.put("success", 1);
    result.put("message", "上傳成功");
    result.put("url", fileUrl);

    return result;
}
           

這個上傳的參數一定要注意!!請求的參數是這個

editormd-image-file

不然會報

Required request part 'file' is not present

這個錯誤