@Intercepts(before=ParametersInstantiatorInterceptor.class) @RequestScoped public class Servlet3MultipartInterceptor extends java.lang.Object implements MultipartInterceptor
A multipart interceptor based on Servlet3 File Upload. It's only enabled if Servlet Part is avaliable. If you're
using servlet3 upload features, the MultipartConfig.getDirectory()
has no effect.
TODO This interceptor fails in Apache Tomcat 7.x because request.getParts() doesn't work in a Filter
. So you
need to use CommonsUploadMultipartInterceptor
. See bug
https://issues.apache.org/bugzilla/show_bug.cgi?id=49711 and
https://servlet-spec-public.dev.java.net/issues/show_bug.cgi?id=14 for more info.
TODO According JSR315, all form fields are also avaliable via request.getParameter and request.getParameters(), but not all containers implements this issue (Glassfish 3.0 fails).
DefaultMultipartConfig
,
NullMultipartInterceptor
,
MultipartInterceptor
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ACCEPT_MULTIPART |
static java.lang.String |
CONTENT_DISPOSITION_KEY |
Constructor and Description |
---|
Servlet3MultipartInterceptor(javax.servlet.http.HttpServletRequest request,
MutableRequest parameters,
Validator validator) |
Modifier and Type | Method and Description |
---|---|
boolean |
accepts(ResourceMethod method)
Only accept requests that contains multipart headers.
|
protected java.lang.String |
fixIndexedParameters(java.lang.String name) |
protected java.lang.String |
getFileName(javax.servlet.http.Part part)
Get the filename of the part.
|
protected java.lang.String |
getStringValue(javax.servlet.http.Part part)
Get the content of a part as String.
|
void |
intercept(InterceptorStack stack,
ResourceMethod method,
java.lang.Object resourceInstance) |
protected boolean |
isField(javax.servlet.http.Part part)
Returns true if the part is a field, false otherwise.
|
protected void |
reportSizeLimitExceeded(java.lang.IllegalStateException e)
This method is called when the max upload size is reached.
|
public static final java.lang.String ACCEPT_MULTIPART
public static final java.lang.String CONTENT_DISPOSITION_KEY
public Servlet3MultipartInterceptor(javax.servlet.http.HttpServletRequest request, MutableRequest parameters, Validator validator)
public boolean accepts(ResourceMethod method)
accepts
in interface Interceptor
public void intercept(InterceptorStack stack, ResourceMethod method, java.lang.Object resourceInstance) throws InterceptionException
intercept
in interface Interceptor
InterceptionException
protected void reportSizeLimitExceeded(java.lang.IllegalStateException e)
e
- protected boolean isField(javax.servlet.http.Part part)
protected java.lang.String getFileName(javax.servlet.http.Part part)
protected java.lang.String getStringValue(javax.servlet.http.Part part) throws java.io.IOException
java.io.IOException
protected java.lang.String fixIndexedParameters(java.lang.String name)
Copyright © 2013 Caelum. All Rights Reserved.