微信小程序上传文件
时间:2020-04-17 09:51:24
收藏:0
阅读:110
项目:spring boot + mybatis plus + spring + redis
测试接口
@ApiOperation(value = "单文件上传测试接口") @PostMapping(value = "/file") public String fileUpload(MultipartFile file) { if (file.getSize() > 0) { System.out.println("上传成功"); } return ""; }
swagger或postman测试发现,file参数接收不到文件,始终为null。
解决方案:
<!-- <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>1.3.2</version> </dependency>--> <!-- <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.2</version> </dependency>-->
/*@Configuration public class MultipartResolverConfig { @Bean(name = "multipartResolver") public MultipartResolver multipartResolver(){ CommonsMultipartResolver resolver = new CommonsMultipartResolver(); //上传文件大小 10M 10*1024*1024 resolver.setMaxUploadSize(10*1024*1024); resolver.setDefaultEncoding("UTF-8"); return resolver; } }*/
结束
评论(0)