Class AbstractFileUploadInterceptor

java.lang.Object
org.apache.struts2.interceptor.AbstractInterceptor
org.apache.struts2.interceptor.AbstractFileUploadInterceptor
All Implemented Interfaces:
Serializable, ConditionalInterceptor, Interceptor
Direct Known Subclasses:
ActionFileUploadInterceptor

public abstract class AbstractFileUploadInterceptor extends AbstractInterceptor
See Also:
  • Field Details

    • STRUTS_MESSAGES_BYPASS_REQUEST_KEY

      public static final String STRUTS_MESSAGES_BYPASS_REQUEST_KEY
      See Also:
    • STRUTS_MESSAGES_ERROR_UPLOADING_KEY

      public static final String STRUTS_MESSAGES_ERROR_UPLOADING_KEY
      See Also:
    • STRUTS_MESSAGES_ERROR_FILE_TOO_LARGE_KEY

      public static final String STRUTS_MESSAGES_ERROR_FILE_TOO_LARGE_KEY
      See Also:
    • STRUTS_MESSAGES_INVALID_FILE_KEY

      public static final String STRUTS_MESSAGES_INVALID_FILE_KEY
      See Also:
    • STRUTS_MESSAGES_INVALID_CONTENT_TYPE_KEY

      @Deprecated(since="7.3.0", forRemoval=true) public static final String STRUTS_MESSAGES_INVALID_CONTENT_TYPE_KEY
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 7.3.0, no longer used. The unreachable content-type null-check in acceptFile() that referenced this key was removed as part of the in-memory upload optimization (WW-5413); there is no replacement. This constant will be removed in a future version.
      See Also:
    • STRUTS_MESSAGES_ERROR_CONTENT_TYPE_NOT_ALLOWED_KEY

      public static final String STRUTS_MESSAGES_ERROR_CONTENT_TYPE_NOT_ALLOWED_KEY
      See Also:
    • STRUTS_MESSAGES_ERROR_FILE_EXTENSION_NOT_ALLOWED_KEY

      public static final String STRUTS_MESSAGES_ERROR_FILE_EXTENSION_NOT_ALLOWED_KEY
      See Also:
    • STRUTS_MESSAGES_ERROR_UPLOAD_POLICY_UNRESOLVED_KEY

      public static final String STRUTS_MESSAGES_ERROR_UPLOAD_POLICY_UNRESOLVED_KEY
      See Also:
  • Constructor Details

    • AbstractFileUploadInterceptor

      public AbstractFileUploadInterceptor()
  • Method Details

    • setMatcher

      public void setMatcher(ContentTypeMatcher<Object> matcher)
    • setContainer

      public void setContainer(Container container)
    • setAllowedExtensions

      public void setAllowedExtensions(String allowedExtensions)
      Sets the allowed extensions. Applied at configuration time only; the effective policy for an invocation is a copy, see ActionFileUploadInterceptor.newLazyParams().
      Parameters:
      allowedExtensions - A comma-delimited list of extensions
    • setAllowedTypes

      public void setAllowedTypes(String allowedTypes)
      Sets the allowed mimetypes. Applied at configuration time only; the effective policy for an invocation is a copy, see ActionFileUploadInterceptor.newLazyParams().
      Parameters:
      allowedTypes - A comma-delimited list of types
    • setMaximumSize

      public void setMaximumSize(Long maximumSize)
      Sets the maximum size of an uploaded file. Applied at configuration time only; the effective policy for an invocation is a copy, see ActionFileUploadInterceptor.newLazyParams().
      Parameters:
      maximumSize - The maximum size in bytes
    • copyConfiguredPolicy

      protected UploadPolicy copyConfiguredPolicy()
      Returns:
      an independent copy of the configured policy, to be resolved for one invocation
      Since:
      7.3.0
    • acceptFile

      protected boolean acceptFile(UploadPolicy policy, 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:
      policy - - the effective upload policy for this invocation.
      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.
    • 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)