如何将MultipartFile转换为字节流
//或将多部分文件保存到数据库的任何其他解决方案。我尝试用这种方式,但出现错误。
File fileOne = new File("file.getOrignalFileName");//what should be kept inside this method byte[] bFile = new byte[(int) fileOne.length()];
try {
FileInputStream fileInputStream = new FileInputStream(fileOne);
//convert file into array of bytes
fileInputStream.read(bFile);
fileInputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
questionDao.saveImage(bFile);
回答:
MultipartFile file;byte [] byteArr=file.getBytes();
InputStream inputStream = new ByteArrayInputStream(byteArr);
以上是 如何将MultipartFile转换为字节流 的全部内容, 来源链接: utcz.com/qa/436270.html