List of usage examples for org.apache.commons.fileupload.disk DiskFileItemFactory setRepository
public void setRepository(File repository)
From source file:org.ow2.proactive_grid_cloud_portal.scheduler.server.FlatJobServlet.java
private void upload(HttpServletRequest request, HttpServletResponse response) { response.setContentType("text/html"); DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setSizeThreshold(4096);/* ww w.ja v a 2 s.co m*/ factory.setRepository(new File(System.getProperty("java.io.tmpdir"))); ServletFileUpload upload = new ServletFileUpload(factory); upload.setSizeMax(1000000); String callbackName = null; try { List<?> fileItems = upload.parseRequest(request); Iterator<?> i = fileItems.iterator(); String commandFile = null; String name = null; String selectionScript = null; String selectionScriptExtension = null; String sessionId = null; while (i.hasNext()) { FileItem fi = (FileItem) i.next(); if (fi.isFormField()) { if (fi.getFieldName().equals("jobName")) { name = fi.getString(); if (name.trim().length() == 0) name = null; } else if (fi.getFieldName().equals("sessionId")) { sessionId = fi.getString(); } else if (fi.getFieldName().equals("flatCallback")) { callbackName = fi.getString(); } } else { if (fi.getFieldName().equals("commandFile")) { commandFile = IOUtils.toString(fi.getInputStream()); if (commandFile.trim().length() == 0) commandFile = null; } else if (fi.getFieldName().equals("selectionScript")) { if (fi.getName().indexOf('.') == -1) { selectionScriptExtension = "js"; } else { selectionScriptExtension = fi.getName().substring(fi.getName().lastIndexOf('.') + 1); } selectionScript = IOUtils.toString(fi.getInputStream()); if (selectionScript.trim().length() == 0) selectionScript = null; } } } String ret; if (commandFile == null) { ret = "{ \"errorMessage\" : \"Missing parameter: command file\" }"; } else if (sessionId == null) { ret = "{ \"errorMessage\" : \"Missing parameter: sessionId\" }"; } else if (name == null) { ret = "{ \"errorMessage\" : \"Missing parameter: job name\" }"; } else { ret = ((SchedulerServiceImpl) SchedulerServiceImpl.get()).submitFlatJob(sessionId, commandFile, name, selectionScript, selectionScriptExtension); } /* writing the callback name in as an inlined script, * so that the browser, upon receiving it, will evaluate * the JS and call the function */ response.getWriter().write("<script type='text/javascript'>"); response.getWriter().write("window.top." + callbackName + "(" + ret + ");"); response.getWriter().write("</script>"); } catch (RestServerException e) { try { response.getWriter().write("<script type='text/javascript'>"); response.getWriter().write("window.top." + callbackName + " (" + e.getMessage() + ")"); response.getWriter().write("</script>"); } catch (Throwable e1) { LOGGER.warn("Failed to write script back to client", e); } } catch (Exception e) { try { String tw = "<script type='text/javascript'>"; tw += "window.top." + callbackName + "({ \"errorMessage\" : \"" + e.getMessage() + "\" });"; tw += "</script>"; response.getWriter().write(tw); } catch (IOException e1) { LOGGER.warn("Failed to write script back to client", e); } } }
From source file:org.ow2.proactive_grid_cloud_portal.scheduler.server.UploadServlet.java
private void upload(HttpServletRequest request, HttpServletResponse response) { response.setContentType("text/html"); File job = null;//ww w. j a v a2 s . c o m try { DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setSizeThreshold(4096); factory.setRepository(new File(System.getProperty("java.io.tmpdir"))); ServletFileUpload upload = new ServletFileUpload(factory); upload.setSizeMax(1000000); List<?> fileItems = upload.parseRequest(request); Iterator<?> i = fileItems.iterator(); String sessionId = null; boolean edit = false; /* * * edit=0, simply submit the job descriptor * edit=1, open the descriptor and return * it as a string */ while (i.hasNext()) { FileItem fi = (FileItem) i.next(); if (fi.isFormField()) { if (fi.getFieldName().equals("sessionId")) { sessionId = fi.getString(); } else if (fi.getFieldName().equals("edit")) { if (fi.getString().equals("1")) { edit = true; } else { edit = false; } } } else { job = File.createTempFile("job_upload", ".xml"); fi.write(job); } fi.delete(); } boolean isJar = isJarFile(job); if (!isJar) { // this _loosely_ checks that the file we got is an XML file try { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.parse(job); if (edit) { // don't go on with edition if there are no variables if (doc.getElementsByTagName("variables").getLength() < 1 || doc.getElementsByTagName("variable").getLength() < 1) { response.getWriter().write("This job descriptor contains no variable definition.<br>" + "Uncheck <strong>Edit variables</strong> or submit another descriptor."); return; } } } catch (Throwable e) { response.getWriter().write("Job descriptor must be valid XML<br>" + e.getMessage()); return; } } if (edit && !isJar) { String ret = IOUtils.toString(new FileInputStream(job), "UTF-8"); response.getWriter().write("{ \"jobEdit\" : \"" + Base64Utils.toBase64(ret.getBytes()) + "\" }"); } else { String responseS = ((SchedulerServiceImpl) Service.get()).submitXMLFile(sessionId, job); if (responseS == null || responseS.length() == 0) { response.getWriter().write("Job submission returned without a value!"); } else { response.getWriter().write(responseS); } } } catch (Exception e) { try { String msg = e.getMessage().replace("<", "<").replace(">", ">"); response.getWriter().write(msg); } catch (IOException ignored) { } } finally { if (job != null) job.delete(); } }
From source file:org.primefaces.webapp.filter.FileUploadFilter.java
protected FileItemFactory createFileItemFactory(HttpServletRequest httpServletRequest) { DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory(); if (thresholdSize != null) { diskFileItemFactory.setSizeThreshold(Integer.valueOf(thresholdSize)); }//from ww w . j av a 2 s . c o m if (uploadDir != null) { diskFileItemFactory.setRepository(new File(uploadDir)); } FileCleaningTracker fileCleaningTracker = FileCleanerCleanup .getFileCleaningTracker(httpServletRequest.getSession().getServletContext()); if (fileCleaningTracker != null) { diskFileItemFactory.setFileCleaningTracker(fileCleaningTracker); } return diskFileItemFactory; }
From source file:org.ralasafe.servlet.UserTypeInstallAction.java
/** * //from w w w .j a va 2s . c o m * @param req * @return Object[]{op<String>,userType<UserType>} * @throws ServletException */ private Object[] extractValues(HttpServletRequest req) throws ServletException, IOException { String op = null; UserType userType = new UserType(); String userTypeStoreDir = SystemConstant.getUserTypeStoreDir(); DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setRepository(new File(userTypeStoreDir)); ServletFileUpload upload = new ServletFileUpload(factory); List items; try { items = upload.parseRequest(req); } catch (FileUploadException e) { throw new ServletException(e); } for (Iterator iter = items.iterator(); iter.hasNext();) { FileItem item = (FileItem) iter.next(); if (item.isFormField()) { String fieldName = item.getFieldName(); String value = item.getString(); /* if( value!=null ) { value=new String(value.getBytes("ISO-8859-1"),"UTF-8"); }*/ if ("name".equalsIgnoreCase(fieldName)) { userType.setName(value); } else if ("desc".equalsIgnoreCase(fieldName)) { userType.setDesc(value); } else if ("op".equalsIgnoreCase(fieldName)) { op = value; } } else { String clientFile = item.getName(); int index = clientFile.lastIndexOf("\\"); if (index == -1) { index = clientFile.lastIndexOf("/"); } String serverFile = userTypeStoreDir + File.separator + sdf.format(new Date()) + "-" + clientFile.substring(index + 1); userType.setSrcFile(serverFile); File f = new File(serverFile); ; try { item.write(f); } catch (Exception e) { throw new ServletException(e); } UserMetadataParser parser = new UserMetadataParser(); UserMetadata metadata = parser.parse(f.getAbsolutePath()); userType.setUserMetadata(metadata); } } return new Object[] { op, userType }; }
From source file:org.rhq.coregui.server.gwt.FileUploadServlet.java
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { HttpSession session = req.getSession(); session.setMaxInactiveInterval(MAX_INACTIVE_INTERVAL); if (ServletFileUpload.isMultipartContent(req)) { DiskFileItemFactory fileItemFactory = new DiskFileItemFactory(); if (tmpDir == null) { tmpDir = LookupUtil.getCoreServer().getJBossServerTempDir(); }/*from w w w .j a v a 2 s . c o m*/ fileItemFactory.setRepository(tmpDir); //fileItemFactory.setSizeThreshold(0); ServletFileUpload servletFileUpload = new ServletFileUpload(fileItemFactory); List<FileItem> fileItemsList; try { fileItemsList = servletFileUpload.parseRequest(req); } catch (FileUploadException e) { writeExceptionResponse(resp, "File upload failed", e); return; } List<FileItem> actualFiles = new ArrayList<FileItem>(); Map<String, String> formFields = new HashMap<String, String>(); boolean retrieve = false; boolean obfuscate = false; Subject authenticatedSubject = null; for (FileItem fileItem : fileItemsList) { if (fileItem.isFormField()) { if (fileItem.getFieldName() != null) { formFields.put(fileItem.getFieldName(), fileItem.getString()); } if ("retrieve".equals(fileItem.getFieldName())) { retrieve = true; } else if ("obfuscate".equals(fileItem.getFieldName())) { obfuscate = Boolean.parseBoolean(fileItem.getString()); } else if ("sessionid".equals(fileItem.getFieldName())) { int sessionid = Integer.parseInt(fileItem.getString()); SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager(); try { authenticatedSubject = subjectManager.getSubjectBySessionId(sessionid); } catch (Exception e) { throw new ServletException("Cannot authenticate request", e); } } fileItem.delete(); } else { // file item contains an actual uploaded file actualFiles.add(fileItem); log("file was uploaded: " + fileItem.getName()); } } if (authenticatedSubject == null) { for (FileItem fileItem : actualFiles) { fileItem.delete(); } throw new ServletException("Cannot process unauthenticated request"); } if (retrieve && actualFiles.size() == 1) { // sending in "retrieve" form element with a single file means the client just wants the content echoed back resp.setContentType("text/html"); FileItem fileItem = actualFiles.get(0); ServletOutputStream outputStream = resp.getOutputStream(); outputStream.print("<html>"); InputStream inputStream = fileItem.getInputStream(); try { // we have to HTML escape inputStream before writing it to outputStream StreamUtil.copy(inputStream, outputStream, false, true); } finally { inputStream.close(); } outputStream.print("</html>"); outputStream.flush(); fileItem.delete(); } else { Map<String, File> allUploadedFiles = new HashMap<String, File>(); // maps form field name to the actual file Map<String, String> allUploadedFileNames = new HashMap<String, String>(); // maps form field name to upload file name for (FileItem fileItem : actualFiles) { File theFile = forceToFile(fileItem); if (obfuscate) { // The commons fileupload API has a file tracker that deletes the file when the File object is garbage collected (huh?). // Because we will be using these files later, and because they are going to be obfuscated, we don't want this to happen, // so just rename the file to move it away from the file tracker and thus won't get // prematurely deleted before we get a chance to use it. File movedFile = new File(theFile.getAbsolutePath() + ".temp"); if (theFile.renameTo(movedFile)) { theFile = movedFile; } try { FileUtil.compressFile(theFile); // we really just compress it with our special compressor since its faster than obsfucation } catch (Exception e) { throw new ServletException("Cannot obfuscate uploaded files", e); } } allUploadedFiles.put(fileItem.getFieldName(), theFile); allUploadedFileNames.put(fileItem.getFieldName(), (fileItem.getName() != null) ? fileItem.getName() : theFile.getName()); } processUploadedFiles(authenticatedSubject, allUploadedFiles, allUploadedFileNames, formFields, req, resp); } } }
From source file:org.sakaiproject.myshowcase.servlet.MyShowcaseFileUploadServlet.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {/* ww w. jav a2 s. com*/ List fileItemsList = null; String input1 = request.getParameter("input1"); String input2 = request.getParameter("input2"); String input4 = request.getParameter("input4"); if (ServletFileUpload.isMultipartContent(request)) { ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory()); fileItemsList = servletFileUpload.parseRequest(request); DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory(); diskFileItemFactory.setSizeThreshold(40960); /* the unit is bytes */ String homeDirId = MyShowcaseConfigValues.getInstance().getFileUploadHomeDir(); File repositoryPath = null; String homeDir = ""; if (homeDirId.equals("ownerName")) { homeDir = getOwnerName(fileItemsList); } else if (homeDirId.equals("ownerId")) { homeDir = getOwnerId(fileItemsList); } repositoryPath = new File(getRepositoryPath(homeDir)); diskFileItemFactory.setRepository(repositoryPath); servletFileUpload.setSizeMax(81920); /* the unit is bytes */ Iterator it = fileItemsList.iterator(); while (it.hasNext()) { FileItem fileItem = (FileItem) it.next(); if (fileItem.isFormField()) { } else { String fileName = fileItem.getName(); fileName = getRepositoryPath(homeDir) + fileName; File uploadedFile = new File(fileName); fileItem.write(uploadedFile); isValidFileType(fileName); } } } else { System.out.println("Not Multipart Request"); } IMyShowcaseService myshowcaseService = getMyShowcaseService(); String ownerId = getOwnerId(fileItemsList); Owner owner = myshowcaseService.getOwnerById(new Long(ownerId)); String aType = getType(fileItemsList); String aTitle = getTitle(fileItemsList); String aDescription = getDescription(fileItemsList); String aDataValue = getDataValue(fileItemsList); // Save Artefact Artefact artefact = new Artefact(); ArtefactDetail artefactDetail = new ArtefactDetail(); ArtefactType artefactType = myshowcaseService.getArtefactTypeByName(aType); artefact.setOwner(owner); artefact.setDescription(aDescription); artefact.setName(aTitle); artefact.setShortDesc(aTitle); artefact.setType(artefactType); artefactDetail.setFileName(aDataValue); artefactDetail.setFileType(getFileType(aDataValue)); artefactDetail.setFilePath(getRepositoryPath(ownerId)); artefactDetail.setDetail(aDataValue); artefact.setArtefactDetail(artefactDetail); myshowcaseService.saveArtefact(artefact); } catch (Exception e) { System.out.println(e.toString()); } // response.setContentType("application/json"); response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); PrintWriter out = response.getWriter(); out.write("<html>"); out.write("<head>"); out.write("<title>File Upload</title>"); out.write("</head>"); out.write("<body>"); out.write("File uploaded"); out.write("<script type=\"text/javascript\">"); out.write("parent.$.fancybox.close();"); out.write("</script>"); out.write("</body>"); out.write("</html>"); out.flush(); out.close(); }
From source file:org.sakaiproject.myshowcase.tool.MyShowcaseSaveArtefactFileController.java
protected void upload(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {/*from w w w . j a v a 2s .co m*/ if (ServletFileUpload.isMultipartContent(request)) { ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory()); List fileItemsList = servletFileUpload.parseRequest(request); DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory(); diskFileItemFactory.setSizeThreshold(40960); /* the unit is bytes */ String homeDirId = MyShowcaseConfigValues.getInstance().getFileUploadHomeDir(); File repositoryPath = null; String homeDir = ""; if (homeDirId.equals("ownerName")) { // homeDir = getOwnerName(fileItemsList) ; } else if (homeDirId.equals("ownerId")) { // homeDir = getOwnerId(fileItemsList) ; } repositoryPath = new File(getRepositoryPath(homeDir)); diskFileItemFactory.setRepository(repositoryPath); servletFileUpload.setSizeMax(81920); /* the unit is bytes */ Iterator it = fileItemsList.iterator(); while (it.hasNext()) { FileItem fileItem = (FileItem) it.next(); if (fileItem.isFormField()) { } else { String fileName = fileItem.getName(); System.out.println("++++ A file(1) = " + fileName); fileName = getRepositoryPath(homeDir) + fileName; System.out.println("++++ A file(2) = " + fileName); File uploadedFile = new File(fileName); fileItem.write(uploadedFile); System.out.println("YES --- File (" + fileName + ") has been written."); System.out.println("==========================="); // isValidFileType(fileName); System.out.println("==========================="); } } } else { System.out.println("Not Multipart Request"); } } catch (Exception e) { System.out.println(e.toString()); } }
From source file:org.sakaiproject.util.RequestFilter.java
/** * if the filter is configured to parse file uploads, AND the request is multipart (typically a file upload), then parse the * request.// ww w . jav a 2s. c o m * * @return If there is a file upload, and the filter handles it, return the wrapped request that has the results of the parsed * file upload. Parses the files using Apache commons-fileuplaod. Exposes the results through a wrapped request. Files * are available like: fileItem = (FileItem) request.getAttribute("myHtmlFileUploadId"); */ protected HttpServletRequest handleFileUpload(HttpServletRequest req, HttpServletResponse resp, List<FileItem> tempFiles) throws ServletException, UnsupportedEncodingException { if (!m_uploadEnabled || !ServletFileUpload.isMultipartContent(req) || req.getAttribute(ATTR_UPLOADS_DONE) != null) { return req; } // mark that the uploads have been parsed, so they aren't parsed again on this request req.setAttribute(ATTR_UPLOADS_DONE, ATTR_UPLOADS_DONE); // Result - map that will be created of request parameters, // parsed parameters, and uploaded files Map map = new HashMap(); // parse using commons-fileupload // Create a factory for disk-based file items DiskFileItemFactory factory = new DiskFileItemFactory(); // set the factory parameters: the temp dir and the keep-in-memory-if-smaller threshold if (m_uploadTempDir != null) factory.setRepository(new File(m_uploadTempDir)); if (m_uploadThreshold > 0) factory.setSizeThreshold(m_uploadThreshold); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); // set the encoding String encoding = req.getCharacterEncoding(); if (encoding != null && encoding.length() > 0) upload.setHeaderEncoding(encoding); // set the max upload size long uploadMax = -1; if (m_uploadMaxSize > 0) uploadMax = m_uploadMaxSize; // check for request-scoped override to upload.max (value in megs) String override = req.getParameter(CONFIG_UPLOAD_MAX); if (override != null) { try { // get the max in bytes uploadMax = Long.parseLong(override) * 1024L * 1024L; } catch (NumberFormatException e) { M_log.warn(CONFIG_UPLOAD_MAX + " set to non-numeric: " + override); } } // limit to the ceiling if (uploadMax > m_uploadCeiling) { /** * KNL-602 This is the expected behaviour of the request filter honouring the globaly configured * value -DH */ M_log.debug("Upload size exceeds ceiling: " + ((uploadMax / 1024L) / 1024L) + " > " + ((m_uploadCeiling / 1024L) / 1024L) + " megs"); uploadMax = m_uploadCeiling; } // to let commons-fileupload throw the exception on over-max, and also halt full processing of input fields if (!m_uploadContinue) { // TODO: when we switch to commons-fileupload 1.2 // // either per file or overall request, as configured // if (m_uploadMaxPerFile) // { // upload.setFileSizeMax(uploadMax); // } // else // { // upload.setSizeMax(uploadMax); // } upload.setSizeMax(uploadMax); } try { // parse multipart encoded parameters boolean uploadOk = true; List list = upload.parseRequest(req); for (int i = 0; i < list.size(); i++) { FileItem item = (FileItem) list.get(i); if (item.isFormField()) { String str = item.getString(encoding); Object obj = map.get(item.getFieldName()); if (obj == null) { map.put(item.getFieldName(), new String[] { str }); } else if (obj instanceof String[]) { String[] old_vals = (String[]) obj; String[] values = new String[old_vals.length + 1]; for (int i1 = 0; i1 < old_vals.length; i1++) { values[i1] = old_vals[i1]; } values[values.length - 1] = str; map.put(item.getFieldName(), values); } else if (obj instanceof String) { String[] values = new String[2]; values[0] = (String) obj; values[1] = str; map.put(item.getFieldName(), values); } } else { // collect it for delete at the end of the request tempFiles.add(item); // check the max, unless we are letting commons-fileupload throw exception on max exceeded // Note: the continue option assumes the max is per-file, not overall. if (m_uploadContinue && (item.getSize() > uploadMax)) { uploadOk = false; M_log.info("Upload size limit exceeded: " + ((uploadMax / 1024L) / 1024L)); req.setAttribute("upload.status", "size_limit_exceeded"); // TODO: for 1.2 commons-fileupload, switch this to a FileSizeLimitExceededException req.setAttribute("upload.exception", new FileUploadBase.SizeLimitExceededException("", item.getSize(), uploadMax)); req.setAttribute("upload.limit", Long.valueOf((uploadMax / 1024L) / 1024L)); } else { req.setAttribute(item.getFieldName(), item); } } } // unless we had an upload file that exceeded max, set the upload status to "ok" if (uploadOk) { req.setAttribute("upload.status", "ok"); } } catch (FileUploadBase.SizeLimitExceededException ex) { M_log.info("Upload size limit exceeded: " + ((upload.getSizeMax() / 1024L) / 1024L)); // DON'T throw an exception, instead note the exception // so that the tool down-the-line can handle the problem req.setAttribute("upload.status", "size_limit_exceeded"); req.setAttribute("upload.exception", ex); req.setAttribute("upload.limit", Long.valueOf((upload.getSizeMax() / 1024L) / 1024L)); } // TODO: put in for commons-fileupload 1.2 // catch (FileUploadBase.FileSizeLimitExceededException ex) // { // M_log.info("Upload size limit exceeded: " + ((upload.getFileSizeMax() / 1024L) / 1024L)); // // // DON'T throw an exception, instead note the exception // // so that the tool down-the-line can handle the problem // req.setAttribute("upload.status", "size_limit_exceeded"); // req.setAttribute("upload.exception", ex); // req.setAttribute("upload.limit", new Long((upload.getFileSizeMax() / 1024L) / 1024L)); // } catch (FileUploadException ex) { M_log.info("Unexpected exception in upload parsing", ex); req.setAttribute("upload.status", "exception"); req.setAttribute("upload.exception", ex); } // add any parameters that were in the URL - make sure to get multiples for (Enumeration e = req.getParameterNames(); e.hasMoreElements();) { String name = (String) e.nextElement(); String[] values = req.getParameterValues(name); map.put(name, values); } // return a wrapped response that exposes the parsed parameters and files return new WrappedRequestFileUpload(req, map); }
From source file:org.seasar.teeda.extension.filter.MultipartFormDataRequestWrapper.java
/** * @param request //from w w w. ja v a2s .co m * @param maxFileSize * @param thresholdSize * @param repositoryPath */ public MultipartFormDataRequestWrapper(final HttpServletRequest request, final int maxSize, final int maxFileSize, final int thresholdSize, final String repositoryPath) { super(request); final DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setSizeThreshold(thresholdSize); if (!StringUtil.isEmpty(repositoryPath)) { factory.setRepository(new File(repositoryPath)); } fileUpload = new ServletFileUpload(factory); fileUpload.setSizeMax(maxSize); fileUpload.setFileSizeMax(maxFileSize); parseRequest(request); }
From source file:org.seasar.teeda.extension.portlet.MultipartFormDataActionRequestWrapper.java
/** * @param request /*from w ww . ja v a2s .co m*/ * @param maxSize * @param maxFileSize * @param thresholdSize * @param repositoryPath */ public MultipartFormDataActionRequestWrapper(final ActionRequest request, final int maxSize, final int maxFileSize, final int thresholdSize, final String repositoryPath, final String encoding) { this.request = request; final DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setSizeThreshold(thresholdSize); if (!StringUtil.isEmpty(repositoryPath)) { factory.setRepository(new File(repositoryPath)); } fileUpload = new PortletFileUpload(factory); fileUpload.setSizeMax(maxSize); fileUpload.setFileSizeMax(maxFileSize); this.encoding = encoding; parseRequest(request); }