yml配置
spring:
servlet:
multipart:
max-file-size: 10MB
max-request-size: 30MB
controller代码
@ResponseBody
@PostMapping("/OriPicAdd")
public ResultVO handleFileUpload(HttpServletRequest request, Integer typeId) {
String url = "http://localhost:8333/image/";
String typeName = typeMapper.selectByPrimaryKey(typeId).getTypeName();
String realPath = "D:\\TEST\\" + typeName;
File dest = new File(realPath);
//检测目录是否存在
if (!dest.exists()) {
dest.mkdirs();
}
List<MultipartFile> files = ((MultipartHttpServletRequest) request).getFiles("file");
MultipartFile file;
BufferedOutputStream stream = null;
log.info("------------------");
log.info("成功接收files:" + files);
for (int i = 0; i < files.size(); ++