5
//或者将多部分文件保存到DB的任何其他解决方案。 我试过这种方式,但得到错误。如何将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);
}
你得到什么错误? –
你有什么错误?它如何保存在数据库中(使用ORM映射?)哪种Multipart文件正在使用(MIME,JMS,..)? – Filip
我正在尝试使用ORM映射将图像文件(PNG)它的工作 –