org.apache.struts2.interceptor

## Class AbstractFileUploadInterceptor

- java.lang.Object
- - com.opensymphony.xwork2.interceptor.AbstractInterceptor
  - - org.apache.struts2.interceptor.AbstractFileUploadInterceptor

- All Implemented Interfaces:
    ConditionalInterceptor, Interceptor, Serializable
  Direct Known Subclasses:
    ActionFileUploadInterceptor, FileUploadInterceptor

      public abstract class AbstractFileUploadInterceptor
      extends AbstractInterceptor

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `STRUTS_MESSAGES_BYPASS_REQUEST_KEY`
    `static String` | `STRUTS_MESSAGES_ERROR_CONTENT_TYPE_NOT_ALLOWED_KEY`
    `static String` | `STRUTS_MESSAGES_ERROR_FILE_EXTENSION_NOT_ALLOWED_KEY`
    `static String` | `STRUTS_MESSAGES_ERROR_FILE_TOO_LARGE_KEY`
    `static String` | `STRUTS_MESSAGES_ERROR_UPLOADING_KEY`
    `static String` | `STRUTS_MESSAGES_INVALID_CONTENT_TYPE_KEY`
    `static String` | `STRUTS_MESSAGES_INVALID_FILE_KEY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractFileUploadInterceptor()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `acceptFile(Object action, UploadedFile file, String originalFilename, String contentType, String inputName)` Override for added functionality.
    `protected void` | `applyValidation(Object action, MultiPartRequestWrapper multiWrapper)`
    `protected String` | `getTextMessage(Object action, String messageKey, String[] args)`
    `protected String` | `getTextMessage(String messageKey, String[] args)`
    `protected TextProvider` | `getTextProvider(Object action)`
    `protected boolean` | `isNonEmpty(Object[] objArray)`
    `void` | `setAllowedExtensions(String allowedExtensions)` Sets the allowed extensions
    `void` | `setAllowedTypes(String allowedTypes)` Sets the allowed mimetypes
    `void` | `setContainer(Container container)`
    `void` | `setMatcher(ContentTypeMatcher<Object> matcher)`
    `void` | `setMaximumSize(Long maximumSize)` Sets the maximum size of an uploaded file

    - ### Methods inherited from class com.opensymphony.xwork2.interceptor.AbstractInterceptor

      `destroy, init, intercept, setDisabled, shouldIntercept`

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

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

- - ### Field Detail

    - #### STRUTS_MESSAGES_BYPASS_REQUEST_KEY

          public static final String STRUTS_MESSAGES_BYPASS_REQUEST_KEY

      See Also:
        Constant Field Values

    - #### STRUTS_MESSAGES_ERROR_UPLOADING_KEY

          public static final String STRUTS_MESSAGES_ERROR_UPLOADING_KEY

      See Also:
        Constant Field Values

    - #### STRUTS_MESSAGES_ERROR_FILE_TOO_LARGE_KEY

          public static final String STRUTS_MESSAGES_ERROR_FILE_TOO_LARGE_KEY

      See Also:
        Constant Field Values

    - #### STRUTS_MESSAGES_INVALID_FILE_KEY

          public static final String STRUTS_MESSAGES_INVALID_FILE_KEY

      See Also:
        Constant Field Values

    - #### STRUTS_MESSAGES_INVALID_CONTENT_TYPE_KEY

          public static final String STRUTS_MESSAGES_INVALID_CONTENT_TYPE_KEY

      See Also:
        Constant Field Values

    - #### STRUTS_MESSAGES_ERROR_CONTENT_TYPE_NOT_ALLOWED_KEY

          public static final String STRUTS_MESSAGES_ERROR_CONTENT_TYPE_NOT_ALLOWED_KEY

      See Also:
        Constant Field Values

    - #### STRUTS_MESSAGES_ERROR_FILE_EXTENSION_NOT_ALLOWED_KEY

          public static final String STRUTS_MESSAGES_ERROR_FILE_EXTENSION_NOT_ALLOWED_KEY

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### AbstractFileUploadInterceptor

          public AbstractFileUploadInterceptor()

  - ### Method Detail

    - #### setMatcher

          public void setMatcher(ContentTypeMatcher<Object> matcher)

    - #### setContainer

          public void setContainer(Container container)

    - #### setAllowedExtensions

          public void setAllowedExtensions(String allowedExtensions)

      Sets the allowed extensions
      Parameters:
        `allowedExtensions` - A comma-delimited list of extensions

    - #### setAllowedTypes

          public void setAllowedTypes(String allowedTypes)

      Sets the allowed mimetypes
      Parameters:
        `allowedTypes` - A comma-delimited list of types

    - #### setMaximumSize

          public void setMaximumSize(Long maximumSize)

      Sets the maximum size of an uploaded file
      Parameters:
        `maximumSize` - The maximum size in bytes

    - #### acceptFile

          protected boolean acceptFile(Object action,
                                       UploadedFile file,
                                       String originalFilename,
                                       String contentType,
                                       String inputName)

      Override for added functionality. Checks if the proposed file is acceptable based on contentType and size.
      Parameters:
        `action` - - uploading action for message retrieval.
        `file` - - proposed upload file.
        `originalFilename` - - name of the file.
        `contentType` - - contentType of the file.
        `inputName` - - inputName of the file.
      Returns:
        true if the proposed file is acceptable by contentType and size.

    - #### isNonEmpty

          protected boolean isNonEmpty(Object[] objArray)

    - #### getTextMessage

          protected String getTextMessage(String messageKey,
                                          String[] args)

    - #### getTextMessage

          protected String getTextMessage(Object action,
                                          String messageKey,
                                          String[] args)

    - #### getTextProvider

          protected TextProvider getTextProvider(Object action)

    - #### applyValidation

          protected void applyValidation(Object action,
                                         MultiPartRequestWrapper multiWrapper)

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