Search code examples
fileservletsjboss5.xjava-6apache-commons-fileupload

Apache common file upload empty multipart item list


I have been trying to parse a multipart request by using apache commons file upload over JBOSS 5.1 . The problem is when request is parsed, FileItem list is not being filled .(FileItem list is empty) Here is the code block that is working on windows but not on Unix :

     DiskFileItemFactory factory = new DiskFileItemFactory();
     factory.setSizeThreshold(1024*1024*3);

     factory.setRepository(new File("/root/loads/temp"));

     // Create a new file upload handler
     ServletFileUpload upload = new ServletFileUpload(factory);
     upload.setFileSizeMax(100000);
     upload.setSizeMax(100000);
     boolean isMulti =upload.isMultipartContent(request);

     // Parse the request
     try {

        List<FileItem> items = upload.parseRequest(request);

Note : I am reaching the HTTPServletRequest via HttpEvent.getHTTPServletRequest().Also request has not being handled before.java version = 1.6_021


Solution

  • I found the solution, jboss security and our project's platform rules does not allow to access any file which are not in the specified directory. I used jboss temp directory and can access the items in the request.