内容类型为“的JSP上载文件”;应用程序/八位字节流“;
我正在做一个项目,flash上载一些内容类型为“application/octet stream”的二进制数据,我需要将其保存在Oracle数据库的BLOB列中 我可以使用Commons文件上传吗?内容类型为“的JSP上载文件”;应用程序/八位字节流“;,jsp,Jsp,我正在做一个项目,flash上载一些内容类型为“application/octet stream”的二进制数据,我需要将其保存在Oracle数据库的BLOB列中 我可以使用Commons文件上传吗? 有关于这个的示例代码吗?我只能找到内容类型“multipart/form data”的代码。我尝试了这个,但它似乎不适用于类型“application/octet stream”。我尝试了这个,但它似乎不适用于类型“application/octet stream”。 private byte[]
有关于这个的示例代码吗?我只能找到内容类型“multipart/form data”的代码。我尝试了这个,但它似乎不适用于类型“application/octet stream”。我尝试了这个,但它似乎不适用于类型“application/octet stream”。
private byte[] getByteArrayFromUploadFile(HttpServletRequest request)throws Exception{
ServletFileUpload upload = new ServletFileUpload();
// Parse the request
FileItemIterator iter = null;
try{
iter = upload.getItemIterator(request);
}catch (Exception e) {
System.out.println("Error occured during getting iterator");
}
byte[] readBytes = null;
while (iter.hasNext()) {
FileItemStream item = null;
try{
item = iter.next();
}catch (Exception e) {
System.out.println("Error occured during Iteration");
}
String name = item.getFieldName();
if (!item.isFormField()) {
BufferedInputStream stream = new BufferedInputStream(item.openStream());
readBytes= new byte[stream.available()];
System.out.println("total Number of Bytes:"+ readBytes.length);
stream.read(readBytes);
}
}
return readBytes;
}