org.apache.tomcat.util.http.fileupload.servlet.ServletRequestContext Java Examples
The following examples show how to use
org.apache.tomcat.util.http.fileupload.servlet.ServletRequestContext.
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: 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); } }