org.apache.struts2.dispatcher.multipart

## Class JakartaStreamMultiPartRequest

- java.lang.Object
- - org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest
  - - org.apache.struts2.dispatcher.multipart.JakartaStreamMultiPartRequest

- All Implemented Interfaces:
    MultiPartRequest

      public class JakartaStreamMultiPartRequest
      extends AbstractMultiPartRequest

  Multi-part form data request adapter for Jakarta Commons FileUpload package that leverages the streaming API rather than the traditional non-streaming API.

  For more details see WW-3025

  Since:
    2.3.18

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `JakartaStreamMultiPartRequest.FileInfo` Internal data structure used to store a reference to information needed to later pass post processing data to the `FileUploadInterceptor`.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Map<String,List<JakartaStreamMultiPartRequest.FileInfo>>` | `fileInfos` Map between file fields and file data.
    `protected Map<String,List<String>>` | `parameters` Map between non-file fields and values.

    - ### Fields inherited from class org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest

      `BUFFER_SIZE, bufferSize, defaultEncoding, defaultLocale, errors, maxFiles, maxFileSize, maxSize, maxStringLength`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JakartaStreamMultiPartRequest()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addFileSkippedError(String fileName, javax.servlet.http.HttpServletRequest request)` Add a file skipped message notification for action messages.
    `void` | `cleanUp()` Cleans up all uploaded file, should be called at the end of request
    `protected void` | `createFileInfoFromItemStream(org.apache.commons.fileupload.FileItemStream itemStream, File file)` Creates an internal `FileInfo` structure used to pass information to the `FileUploadInterceptor` during the interceptor stack invocation process.
    `protected File` | `createTemporaryFile(String fileName, String location)` Creates a temporary file based on the given filename and location.
    `String[]` | `getContentType(String fieldName)` Returns the content type(s) of the file(s) associated with the specified field name (as supplied by the client browser), or `null` if no files are associated with the given field name.
    `UploadedFile[]` | `getFile(String fieldName)` Returns a `UploadedFile` object for the filename specified or `null` if no files are associated with the given field name.
    `String[]` | `getFileNames(String fieldName)` Returns a String[] of file names for files associated with the specified input field name
    `Enumeration<String>` | `getFileParameterNames()` Returns an enumeration of the parameter names for uploaded files
    `String[]` | `getFilesystemName(String fieldName)` Returns the file system name(s) of files associated with the given field name or `null` if no files are associated with the given field name.
    `String` | `getParameter(String name)` Returns the specified request parameter.
    `Enumeration<String>` | `getParameterNames()` Returns an enumeration of String parameter names.
    `String[]` | `getParameterValues(String name)` Returns a list of all parameter values associated with a parameter name.
    `protected long` | `getRequestSize(javax.servlet.http.HttpServletRequest request)`
    `protected boolean` | `isRequestSizePermitted(javax.servlet.http.HttpServletRequest request)` Defines whether the request allowed based on content length.
    `void` | `parse(javax.servlet.http.HttpServletRequest request, String saveDir)`
    `protected void` | `processFileItemStreamAsFileField(org.apache.commons.fileupload.FileItemStream itemStream, String location)` Processes the FileItemStream as a file field.
    `protected void` | `processFileItemStreamAsFormField(org.apache.commons.fileupload.FileItemStream itemStream)` Processes the FileItemStream as a Form Field.
    `protected void` | `processUpload(javax.servlet.http.HttpServletRequest request, String saveDir)` Processes the upload.
    `protected boolean` | `streamFileToDisk(org.apache.commons.fileupload.FileItemStream itemStream, File file)` Streams the file upload stream to the specified file.

    - ### Methods inherited from class org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest

      `buildErrorMessage, getCanonicalName, getErrors, setBufferSize, setDefaultEncoding, setLocale, setLocaleProviderFactory, setMaxFiles, setMaxFileSize, setMaxSize, setMaxStringLength`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### fileInfos

          protected Map<String,List<JakartaStreamMultiPartRequest.FileInfo>> fileInfos

      Map between file fields and file data.

    - #### parameters

          protected Map<String,List<String>> parameters

      Map between non-file fields and values.

  - ### Constructor Detail

    - #### JakartaStreamMultiPartRequest

          public JakartaStreamMultiPartRequest()

  - ### Method Detail

    - #### cleanUp

          public void cleanUp()

      Description copied from interface: `MultiPartRequest`
      Cleans up all uploaded file, should be called at the end of request

    - #### getContentType

          public String[] getContentType(String fieldName)

      Description copied from interface: `MultiPartRequest`
      Returns the content type(s) of the file(s) associated with the specified field name (as supplied by the client browser), or `null` if no files are associated with the given field name.
      Parameters:
        `fieldName` - input field name
      Returns:
        an array of content encoding for the specified input field name or `null` if no content type was specified.

    - #### getFile

          public UploadedFile[] getFile(String fieldName)

      Description copied from interface: `MultiPartRequest`
      Returns a `UploadedFile` object for the filename specified or `null` if no files are associated with the given field name.
      Parameters:
        `fieldName` - input field name
      Returns:
        a UploadedFile[] object for files associated with the specified input field name

    - #### getFileNames

          public String[] getFileNames(String fieldName)

      Description copied from interface: `MultiPartRequest`
      Returns a String[] of file names for files associated with the specified input field name
      Parameters:
        `fieldName` - input field name
      Returns:
        a String[] of file names for files associated with the specified input field name

    - #### getFileParameterNames

          public Enumeration<String> getFileParameterNames()

      Description copied from interface: `MultiPartRequest`
      Returns an enumeration of the parameter names for uploaded files
      Returns:
        an enumeration of the parameter names for uploaded files

    - #### getFilesystemName

          public String[] getFilesystemName(String fieldName)

      Description copied from interface: `MultiPartRequest`
      Returns the file system name(s) of files associated with the given field name or `null` if no files are associated with the given field name.
      Parameters:
        `fieldName` - input field name
      Returns:
        the file system name(s) of files associated with the given field name

    - #### getParameter

          public String getParameter(String name)

      Description copied from interface: `MultiPartRequest`
      Returns the specified request parameter.
      Parameters:
        `name` - the name of the parameter to get
      Returns:
        the parameter or `null` if it was not found.

    - #### getParameterNames

          public Enumeration<String> getParameterNames()

      Description copied from interface: `MultiPartRequest`
      Returns an enumeration of String parameter names.
      Returns:
        an enumeration of String parameter names.

    - #### getParameterValues

          public String[] getParameterValues(String name)

      Description copied from interface: `MultiPartRequest`
      Returns a list of all parameter values associated with a parameter name. If there is only one parameter value per name the resulting array will be of length 1.
      Parameters:
        `name` - the name of the parameter.
      Returns:
        an array of all values associated with the parameter name.

    - #### parse

          public void parse(javax.servlet.http.HttpServletRequest request,
                            String saveDir)
                     throws IOException

      Throws:
        `IOException`

    - #### processUpload

          protected void processUpload(javax.servlet.http.HttpServletRequest request,
                                       String saveDir)
                                throws IOException,
                                       org.apache.commons.fileupload.FileUploadException

      Processes the upload.
      Parameters:
        `request` - the servlet request
        `saveDir` - location of the save dir
      Throws:
        `IOException`
        `org.apache.commons.fileupload.FileUploadException`

    - #### isRequestSizePermitted

          protected boolean isRequestSizePermitted(javax.servlet.http.HttpServletRequest request)

      Defines whether the request allowed based on content length.
      Parameters:
        `request` - the servlet request
      Returns:
        true if request size is permitted

    - #### getRequestSize

          protected long getRequestSize(javax.servlet.http.HttpServletRequest request)

      Parameters:
        `request` - the servlet request
      Returns:
        the request content length.

    - #### addFileSkippedError

          protected void addFileSkippedError(String fileName,
                                             javax.servlet.http.HttpServletRequest request)

      Add a file skipped message notification for action messages.
      Parameters:
        `fileName` - file name
        `request` - the servlet request

    - #### processFileItemStreamAsFormField

          protected void processFileItemStreamAsFormField(org.apache.commons.fileupload.FileItemStream itemStream)

      Processes the FileItemStream as a Form Field.
      Parameters:
        `itemStream` - file item stream

    - #### processFileItemStreamAsFileField

          protected void processFileItemStreamAsFileField(org.apache.commons.fileupload.FileItemStream itemStream,
                                                          String location)

      Processes the FileItemStream as a file field.
      Parameters:
        `itemStream` - file item stream
        `location` - location

    - #### createTemporaryFile

          protected File createTemporaryFile(String fileName,
                                             String location)
                                      throws IOException

      Creates a temporary file based on the given filename and location.
      Parameters:
        `fileName` - file name
        `location` - location
      Returns:
        temporary file based on the given filename and location
      Throws:
        `IOException` - in case of IO errors

    - #### streamFileToDisk

          protected boolean streamFileToDisk(org.apache.commons.fileupload.FileItemStream itemStream,
                                             File file)
                                      throws IOException

      Streams the file upload stream to the specified file.
      Parameters:
        `itemStream` - file item stream
        `file` - the file
      Returns:
        true if stream was successfully
      Throws:
        `IOException` - in case of IO errors

    - #### createFileInfoFromItemStream

          protected void createFileInfoFromItemStream(org.apache.commons.fileupload.FileItemStream itemStream,
                                                      File file)

      Creates an internal `FileInfo` structure used to pass information to the `FileUploadInterceptor` during the interceptor stack invocation process.
      Parameters:
        `itemStream` - file item stream
        `file` - the file

Copyright © 2000–2026 Apache Software Foundation. All rights reserved.