Class MultipartServletWebRequestImpl

All Implemented Interfaces:
IMultipartWebRequest

Servlet specific WebRequest subclass for multipart content uploads.
Author:
Jonathan Locke, Eelco Hillenius, Cameron Braid, Ate Douma, Igor Vaynberg (ivaynberg)
  • Constructor Details

    • MultipartServletWebRequestImpl

      public MultipartServletWebRequestImpl(jakarta.servlet.http.HttpServletRequest request, String filterPrefix, Bytes maxSize, String upload) throws org.apache.commons.fileupload2.core.FileUploadException
      Constructor. This constructor will use DiskFileItemFactory to store uploads.
      Parameters:
      request - the servlet request
      filterPrefix - prefix to wicket filter mapping
      maxSize - the maximum size allowed for this request
      upload - upload identifier for UploadInfo
      Throws:
      org.apache.commons.fileupload2.core.FileUploadException - Thrown if something goes wrong with upload
    • MultipartServletWebRequestImpl

      public MultipartServletWebRequestImpl(jakarta.servlet.http.HttpServletRequest request, String filterPrefix, Bytes maxSize, String upload, org.apache.commons.fileupload2.core.FileItemFactory factory) throws org.apache.commons.fileupload2.core.FileUploadException
      Constructor
      Parameters:
      request - the servlet request
      filterPrefix - prefix to wicket filter mapping
      maxSize - the maximum size allowed for this request
      upload - upload identifier for UploadInfo
      factory - DiskFileItemFactory to use when creating file items used to represent uploaded files
      Throws:
      org.apache.commons.fileupload2.core.FileUploadException - Thrown if something goes wrong with upload
  • Method Details

    • parseFileParts

      public void parseFileParts() throws org.apache.commons.fileupload2.core.FileUploadException
      Description copied from class: MultipartServletWebRequest
      Parses the multipart body of the request.
      Specified by:
      parseFileParts in class MultipartServletWebRequest
      Throws:
      org.apache.commons.fileupload2.core.FileUploadException
    • newFileUpload

      protected org.apache.commons.fileupload2.core.AbstractFileUpload newFileUpload(String encoding)
      Factory method for creating new instances of AbstractFileUpload
      Parameters:
      encoding - The encoding to use while reading the data
      Returns:
      A new instance of AbstractFileUpload
    • getFiles

      public Map<String,List<org.apache.commons.fileupload2.core.FileItem>> getFiles()
      Returns:
      Returns the files.
    • getFile

      public List<org.apache.commons.fileupload2.core.FileItem> getFile(String fieldName)
      Gets the file that was uploaded using the given field name.
      Parameters:
      fieldName - the field name that was used for the upload
      Returns:
      the upload with the given field name
    • generatePostParameters

      Overrides:
      generatePostParameters in class ServletWebRequest
    • wantUploadProgressUpdates

      protected boolean wantUploadProgressUpdates()
      Subclasses that want to receive upload notifications should return true. By default, it takes the value from ApplicationSettings.isUploadProgressUpdatesEnabled().
      Returns:
      true if upload status update event should be invoked
    • onUploadStarted

      protected void onUploadStarted(int totalBytes)
      Upload start callback
      Parameters:
      totalBytes -
    • onUploadUpdate

      protected void onUploadUpdate(int bytesUploaded, int total)
      Upload status update callback
      Parameters:
      bytesUploaded -
      total -
    • onUploadCompleted

      protected void onUploadCompleted()
      Upload completed callback
    • newMultipartWebRequest

      public MultipartServletWebRequest newMultipartWebRequest(Bytes maxSize, String upload) throws org.apache.commons.fileupload2.core.FileUploadException
      Description copied from class: ServletWebRequest
      Creates multipart web request from this request.
      Overrides:
      newMultipartWebRequest in class ServletWebRequest
      Parameters:
      maxSize - max allowed size of request
      upload - upload identifier for UploadInfo
      Returns:
      multipart request
      Throws:
      org.apache.commons.fileupload2.core.FileUploadException
    • newMultipartWebRequest

      public MultipartServletWebRequest newMultipartWebRequest(Bytes maxSize, String upload, org.apache.commons.fileupload2.core.FileItemFactory factory) throws org.apache.commons.fileupload2.core.FileUploadException
      Description copied from class: ServletWebRequest
      Creates multipart web request from this request.
      Overrides:
      newMultipartWebRequest in class ServletWebRequest
      Parameters:
      maxSize - max allowed size of request
      upload - upload identifier for UploadInfo
      Returns:
      multipart request
      Throws:
      org.apache.commons.fileupload2.core.FileUploadException
    • getUploadInfo

      public static UploadInfo getUploadInfo(jakarta.servlet.http.HttpServletRequest req, String upload)
      Retrieves UploadInfo from session, null if not found.
      Parameters:
      req - http servlet request, not null
      upload - upload identifier
      Returns:
      UploadInfo object from session, or null if not found
    • setUploadInfo

      public static void setUploadInfo(jakarta.servlet.http.HttpServletRequest req, String upload, UploadInfo uploadInfo)
      Sets the UploadInfo object into session.
      Parameters:
      req - http servlet request, not null
      upload - upload identifier
      uploadInfo - UploadInfo object to be put into session, not null
    • clearUploadInfo

      public static void clearUploadInfo(jakarta.servlet.http.HttpServletRequest req, String upload)
      Clears the UploadInfo object from session if one exists.
      Parameters:
      req - http servlet request, not null
      upload - upload identifier