Package org.apache.struts2.interceptor
Class UploadPolicy
java.lang.Object
org.apache.struts2.interceptor.DisableParams
org.apache.struts2.interceptor.UploadPolicy
- All Implemented Interfaces:
Serializable,InterceptorParams
Per-invocation upload validation policy for
ActionFileUploadInterceptor.
A configured instance is held by the interceptor and copied for each invocation, so lazily resolved values never reach the shared interceptor.
- Since:
- 7.3.0
- See Also:
-
Field Summary
Fields inherited from class org.apache.struts2.interceptor.DisableParams
DISABLED_PARAM -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()booleanvoidsetAllowedExtensions(String allowedExtensions) voidsetAllowedTypes(String allowedTypes) voidsetMaximumSize(Long maximumSize) voidunresolved(String paramName) A parameter that could not be resolved makes this policy unusable: the upload is rejected rather than validated against a partially-resolved policy, so a broken expression cannot silently relax validation.Methods inherited from class org.apache.struts2.interceptor.DisableParams
isDisabled, setDisabled
-
Constructor Details
-
UploadPolicy
public UploadPolicy()
-
-
Method Details
-
setAllowedTypes
- Parameters:
allowedTypes- a comma-delimited list of content types, or null for no restriction
-
setAllowedExtensions
- Parameters:
allowedExtensions- a comma-delimited list of extensions, or null for no restriction
-
setMaximumSize
- Parameters:
maximumSize- the maximum size in bytes, or null for no limit
-
getMaximumSize
-
getAllowedTypes
-
getAllowedExtensions
-
unresolved
A parameter that could not be resolved makes this policy unusable: the upload is rejected rather than validated against a partially-resolved policy, so a broken expression cannot silently relax validation.DisableParams.DISABLED_PARAMis the one exception and is not recorded. It is not a validation dimension: its unresolved value is simplyfalse, which leaves the interceptor running and every other part of the policy intact, so it cannot relax validation. Recording it would let a broken<param name="disabled">${...}</param>reject every upload of the invocation, which is a failure mode of its own rather than a safe default.- Parameters:
paramName- name of the parameter that could not be applied
-
isUnresolved
public boolean isUnresolved() -
getUnresolvedParams
-
copy
- Returns:
- an independent copy, used to seed a per-invocation policy from the configured one
-