code: public static File saveToTempFolder(Part part) throws IOException {
      String filename = getOriginalFileName(part);
      if (filename == null) {
        return null;
      }
  
      File file = new File(FileUtils.getTempDirectory(), filename);
      FileCopyUtils.copy(part.getInputStream(), new FileOutputStream(file));
  
      return file;
    }
docs: Save an Uploaded file to the temp folder keeping it original name