org.apache.struts2.dispatcher.multipart

## Class AbstractMultiPartRequest

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

- All Implemented Interfaces:
    MultiPartRequest
  Direct Known Subclasses:
    JakartaMultiPartRequest, JakartaStreamMultiPartRequest

      public abstract class AbstractMultiPartRequest
      extends Object
      implements MultiPartRequest

  Abstract class with some helper methods, it should be used when starting development of another implementation of `MultiPartRequest`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `BUFFER_SIZE` Defines the internal buffer size used during streaming operations.
    `protected int` | `bufferSize` Specifies the buffer size to use during streaming.
    `protected String` | `defaultEncoding`
    `protected Locale` | `defaultLocale` Localization to be used regarding errors.
    `protected List<LocalizedMessage>` | `errors` Internal list of raised errors to be passed to the the Struts2 framework.
    `protected Long` | `maxFiles` Specifies the maximum number of files in one request.
    `protected Long` | `maxFileSize` Specifies the maximum size per file in the request.
    `protected Long` | `maxSize` Specifies the maximum size of the entire request.
    `protected Long` | `maxStringLength` Specifies the maximum length of a string parameter in a multipart request.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractMultiPartRequest()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected LocalizedMessage` | `buildErrorMessage(Throwable e, Object[] args)` Build error message.
    `protected String` | `getCanonicalName(String originalFileName)`
    `List<LocalizedMessage>` | `getErrors()` Returns a list of error messages that may have occurred while processing the request.
    `void` | `setBufferSize(String bufferSize)`
    `void` | `setDefaultEncoding(String enc)`
    `protected void` | `setLocale(javax.servlet.http.HttpServletRequest request)`
    `void` | `setLocaleProviderFactory(LocaleProviderFactory localeProviderFactory)`
    `void` | `setMaxFiles(String maxFiles)`
    `void` | `setMaxFileSize(String maxFileSize)`
    `void` | `setMaxSize(String maxSize)`
    `void` | `setMaxStringLength(String maxStringLength)`

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

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

    - ### Methods inherited from interface org.apache.struts2.dispatcher.multipart.MultiPartRequest

      `cleanUp, getContentType, getFile, getFileNames, getFileParameterNames, getFilesystemName, getParameter, getParameterNames, getParameterValues, parse`

- - ### Field Detail

    - #### BUFFER_SIZE

          public static final int BUFFER_SIZE

      Defines the internal buffer size used during streaming operations.
      See Also:
        Constant Field Values

    - #### errors

          protected List<LocalizedMessage> errors

      Internal list of raised errors to be passed to the the Struts2 framework.

    - #### maxSize

          protected Long maxSize

      Specifies the maximum size of the entire request.

    - #### maxFiles

          protected Long maxFiles

      Specifies the maximum number of files in one request.

    - #### maxStringLength

          protected Long maxStringLength

      Specifies the maximum length of a string parameter in a multipart request.

    - #### maxFileSize

          protected Long maxFileSize

      Specifies the maximum size per file in the request.

    - #### bufferSize

          protected int bufferSize

      Specifies the buffer size to use during streaming.

    - #### defaultEncoding

          protected String defaultEncoding

    - #### defaultLocale

          protected Locale defaultLocale

      Localization to be used regarding errors.

  - ### Constructor Detail

    - #### AbstractMultiPartRequest

          public AbstractMultiPartRequest()

  - ### Method Detail

    - #### setBufferSize

          public void setBufferSize(String bufferSize)

      Parameters:
        `bufferSize` - Sets the buffer size to be used.

    - #### setDefaultEncoding

          public void setDefaultEncoding(String enc)

    - #### setMaxSize

          public void setMaxSize(String maxSize)

      Parameters:
        `maxSize` - Injects the Struts multipart request maximum size.

    - #### setMaxFiles

          public void setMaxFiles(String maxFiles)

    - #### setMaxFileSize

          public void setMaxFileSize(String maxFileSize)

    - #### setMaxStringLength

          public void setMaxStringLength(String maxStringLength)

    - #### setLocaleProviderFactory

          public void setLocaleProviderFactory(LocaleProviderFactory localeProviderFactory)

    - #### setLocale

          protected void setLocale(javax.servlet.http.HttpServletRequest request)

      Parameters:
        `request` - Inspect the servlet request and set the locale if one wasn't provided by the Struts2 framework.

    - #### buildErrorMessage

          protected LocalizedMessage buildErrorMessage(Throwable e,
                                                       Object[] args)

      Build error message.
      Parameters:
        `e` - the Throwable/Exception
        `args` - arguments
      Returns:
        error message

    - #### getErrors

          public List<LocalizedMessage> getErrors()

      Description copied from interface: `MultiPartRequest`
      Returns a list of error messages that may have occurred while processing the request. If there are no errors, an empty list is returned. If the underlying implementation (ie: pell, cos, jakarta, etc) cannot support providing these errors, an empty list is also returned. This list of errors is reported back to the `MultiPartRequestWrapper`'s errors field.
      Specified by:
        `getErrors` in interface `MultiPartRequest`
      Returns:
        a list of Strings that represent various errors during parsing

    - #### getCanonicalName

          protected String getCanonicalName(String originalFileName)

      Parameters:
        `originalFileName` - file name
      Returns:
        the canonical name based on the supplied filename

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