Java Code Examples for org.apache.tomcat.util.http.fileupload.servlet.ServletRequestContext

The following examples show how to use org.apache.tomcat.util.http.fileupload.servlet.ServletRequestContext. These examples are extracted from open source projects. 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
private List<FileItem> settingsLoadAndParseRequest() throws FileUploadException {
    DiskFileItemFactory factory = new DiskFileItemFactory();
    // files larger than Threshold will be saved to tmpDir on disk

    ServletFileUpload upload = new ServletFileUpload(factory);
    ServletRequestContext uploadContext = new ServletRequestContext(this);
    return upload.parseRequest(uploadContext);
Example 2
Source Project: cloudbreak   Source File:    License: Apache License 2.0 5 votes vote down vote up
public static SaltFile create(HttpServletRequest request) {
    try {
        DiskFileItemFactory factory = new DiskFileItemFactory();
        Path tempDir = Files.createTempDirectory("temp");
        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())) {
                } else {
            } else {
                File uploadedFile = new File(String.format("%s/saltfile%s.tmp", tempDir, UUID.randomUUID()));

        return saltFile;
    } catch (Exception e) {
        throw new StoreFileException("Could not create temp file", e);