直接上代码
# localAddress 为文件路径 例如 “/test/myNote/test.pdf
File pdfFile = new File(localAddress);
FileInputStream inputStream = new FileInputStream(pdfFile);
MultipartFile multipartFile = new MockMultipartFile("file", pdfFile.getName(), "text/plain", IOUtils.toByteArray(inputStream));
参考:https://blog.csdn.net/m0_37589586/article/details/81513151