前言
博主github
博主个人博客http://blog.healerjean.com
习惯了使用OSS傻瓜式上传,是不是都快忘记写原生的上传了,今天小米的项目中需要用一下,所以之类简单总结下 吧
MultipartFile file 方法名字 | 内容 |
---|---|
file.getContentType() | image/png |
file.getOriginalFilename() | AAAA.png |
file.getName() | file |
1、上传
1、FileUtils.copyInputStreamToFile
File localFile = new File(tempFile,fileName);
FileUtils.copyInputStreamToFile(file.getInputStream(),localFile);
2、file.transferTo
我使用这种方式报错了,没有深入研究,网上说是jar包问题
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
File localFile = new File(tempFile,fileName)