Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
内容类型为“的JSP上载文件”;应用程序/八位字节流“;_Jsp - Fatal编程技术网

内容类型为“的JSP上载文件”;应用程序/八位字节流“;

内容类型为“的JSP上载文件”;应用程序/八位字节流“;,jsp,Jsp,我正在做一个项目,flash上载一些内容类型为“application/octet stream”的二进制数据,我需要将其保存在Oracle数据库的BLOB列中 我可以使用Commons文件上传吗? 有关于这个的示例代码吗?我只能找到内容类型“multipart/form data”的代码。我尝试了这个,但它似乎不适用于类型“application/octet stream”。我尝试了这个,但它似乎不适用于类型“application/octet stream”。 private byte[]

我正在做一个项目,flash上载一些内容类型为“application/octet stream”的二进制数据,我需要将其保存在Oracle数据库的BLOB列中

我可以使用Commons文件上传吗?

有关于这个的示例代码吗?我只能找到内容类型“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;
}