Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin-CB authored and yaroslavafenkin committed Sep 6, 2023
1 parent f9b4d44 commit a8d3048
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions core/src/main/java/org/kohsuke/stapler/RequestImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

package org.kohsuke.stapler;

import java.io.File;
import java.nio.file.Files;
import net.sf.json.JSON;
import net.sf.json.JSONArray;
import net.sf.json.JSONException;
Expand Down Expand Up @@ -1050,8 +1052,15 @@ private void parseMultipartFormData() throws ServletException {

parsedFormData = new HashMap<>();
parsedFormDataFormFields = new HashMap<>();
ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());

ServletFileUpload upload;
File tmpDir;
try {
tmpDir = Files.createTempDirectory("jenkins-stapler-uploads").toFile();
} catch (IOException e) {
throw new ServletException("Error creating temporary directory", e);
}
tmpDir.deleteOnExit();
upload = new ServletFileUpload(new DiskFileItemFactory(DiskFileItemFactory.DEFAULT_SIZE_THRESHOLD, tmpDir));
upload.setFileCountMax(FILEUPLOAD_MAX_FILES);
upload.setFileSizeMax(FILEUPLOAD_MAX_FILE_SIZE);
upload.setSizeMax(FILEUPLOAD_MAX_SIZE);
Expand Down

0 comments on commit a8d3048

Please sign in to comment.