org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory Java Examples
The following examples show how to use
org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MultipartToBase64ConverterServletRequest.java From AuTe-Framework with Apache License 2.0 | 5 votes |
private List<FileItem> settingsLoadAndParseRequest() throws FileUploadException { DiskFileItemFactory factory = new DiskFileItemFactory(); // files larger than Threshold will be saved to tmpDir on disk factory.setSizeThreshold(configProperties.getThresholdTmpFileSize()); factory.setRepository(tmpDir); ServletFileUpload upload = new ServletFileUpload(factory); upload.setSizeMax(configProperties.getThresholdFilesSize()); ServletRequestContext uploadContext = new ServletRequestContext(this); return upload.parseRequest(uploadContext); }
Example #2
Source File: WebappContext.java From kbase-doc with Apache License 2.0 | 5 votes |
public WebappContext(ServletContext servletContext, OpenOffice openOffice) { DiskFileItemFactory fileItemFactory = new DiskFileItemFactory(); fileUpload = new ServletFileUpload(fileItemFactory); if (openOffice.getFileSizeMax() != null) { fileUpload.setFileSizeMax(Integer.parseInt(openOffice.getFileSizeMax())); logger.info("max file upload size set to " + openOffice.getFileSizeMax()); } else { logger.warn("max file upload size not set"); } DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration(); if (openOffice.getPort() != null) { String ports = openOffice.getPort(); String[] portArr = ports.split(","); int[] portArrInt = new int[portArr.length]; int i = 0; for (String port : portArr){ portArrInt[i++] = Integer.parseInt(port); } configuration.setPortNumbers(portArrInt); } if (openOffice.getHome() != null) { configuration.setOfficeHome(new File(openOffice.getHome())); } if (StringUtils.isNotBlank(openOffice.getProfile())) { configuration.setTemplateProfileDir(new File(openOffice.getProfile())); } officeManager = configuration.buildOfficeManager(); documentConverter = new OfficeDocumentConverter(officeManager); }
Example #3
Source File: SaltFile.java From cloudbreak with Apache License 2.0 | 5 votes |
public static SaltFile create(HttpServletRequest request) { try { DiskFileItemFactory factory = new DiskFileItemFactory(); Path tempDir = Files.createTempDirectory("temp"); factory.setRepository(tempDir.toFile()); ServletFileUpload upload = new ServletFileUpload(factory); List<FileItem> items = upload.parseRequest(new ServletRequestContext(request)); SaltFile saltFile = new SaltFile(); for (FileItem item : items) { if (item.isFormField()) { if ("path".equals(item.getFieldName())) { saltFile.setPath(item.getString()); } else { saltFile.setTarget(item.getString()); } } else { File uploadedFile = new File(String.format("%s/saltfile%s.tmp", tempDir, UUID.randomUUID())); item.write(uploadedFile); saltFile.setFile(uploadedFile); } } return saltFile; } catch (Exception e) { throw new StoreFileException("Could not create temp file", e); } }