File转为转MultipartFile

如题:

//读取文件
FileInputStream in_file = new FileInputStream(new File(path));

//转MultipartFile
MultipartFile multi = new MockMultipartFile( real_name, in_file);

只需要以上二行就可以,以下是解释在哪个包

MockMultipartFile 类  implements 实现自 MultipartFile
MultipartFile 接口 extends 继承 InputStreamSource

包名:

package org.springframework.mock.web;
package org.springframework.web.multipart;
org.springframework.web.multipart
public interface InputStreamSource {//只有一个方法,获取 InputStream流InputStream getInputStream() throws IOException;
}

 

 


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部