struts2接收android发送的图片保存在文件夹下,并将路径存至DB2数据库,如何直接将图片保存至数据库?
fos=newFileOutputStream(getSavePath()+"/"+getImageFileName());fis=newFileInputStream(...
fos = new FileOutputStream(getSavePath() + "/" + getImageFileName());
fis = new FileInputStream(getImage());
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
fos.write(buffer, 0, len);
}
System.out.println("文件上传成功");
Picture picture= new Picture();
picture.setFileName(request.getParameter("fileName"));
picture.setFilepath(getSavePath());
picture.setFiletype(imageContentType);
picture.setFilePic(blob);
请问如何将fileinputstream转换为blob实现 picture.setFilePic(blob);?
服务器端是struts2+hibernate4+spring3 展开
fis = new FileInputStream(getImage());
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
fos.write(buffer, 0, len);
}
System.out.println("文件上传成功");
Picture picture= new Picture();
picture.setFileName(request.getParameter("fileName"));
picture.setFilepath(getSavePath());
picture.setFiletype(imageContentType);
picture.setFilePic(blob);
请问如何将fileinputstream转换为blob实现 picture.setFilePic(blob);?
服务器端是struts2+hibernate4+spring3 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询