//或将多部分文件保存到数据库的任何其他解决方案。我尝试用这种方式,但出现错误。
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);