Class MultipartFilter
- java.lang.Object
-
- com.jalios.jcms.servlet.JcmsServletFilter
-
- com.jalios.jcms.upload.MultipartFilter
-
- All Implemented Interfaces:
javax.servlet.Filter
public class MultipartFilter extends JcmsServletFilter implements javax.servlet.Filter
Filter for automatic file upload processing. it wrapper HttpServletRequest to pass any form parameters in usuall form (normally they are not accessible cause JSDK web container are not required to implement RFC1867).
Use filter attribute "uploadDir" to set temporary directory. If there is no attribute, then create a unique sub directory in the java.io.tmpdir path.
Use filter attribute "sizeMax" to set max size otherwise use 2048000000L.
Use filter attribute "sizeThreshold" the threshold, in bytes, below which items will be retained in memory and above which they will be stored as a file.. Default value is 4096.
FIXME:FileItem access is done through attributes. By default they are named after the form field name. However you are allowed to supply attributePrefix and/or attributeSuffix that will be used to "decorate" the attribute name. Request parameter is still set with a fake value defined by filter attribute "fakeParam".
- Since:
- jcms-5.7.0
- Author:
- Jean-Philippe Encausse
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CACHE_MULTIPART_PATHINFO
protected javax.servlet.FilterConfig
config
protected long
countMax
protected java.io.File
directory
protected boolean
initFilter
static java.lang.String
PROGRESS_STATUS
protected long
sizeMax
protected int
sizeThreshold
static java.lang.String
UPLOAD_DIR
Name of directory, created inside the temporary directory, that will be used to store temporary upload file.static java.lang.String
UPLOAD_ERROR
-
Constructor Summary
Constructors Constructor Description MultipartFilter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
void
doFilter(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res, javax.servlet.FilterChain chain)
Wraps the ServletRequest into a MultiPart Request if it contains multipart data.static java.util.Map<java.lang.String,java.lang.String>
getFileUploadStatus(java.lang.String field, java.lang.String token)
void
init(javax.servlet.FilterConfig cfg)
void
initFileUpload()
Initialise filter's parameter from FilterConfing and JCMS Propertiesprotected javax.servlet.http.HttpServletRequest
wrapRequest(javax.servlet.http.HttpServletRequest request)
Wrap the request into a MultipartRequest if we are in MultipartContent with upload-
Methods inherited from class com.jalios.jcms.servlet.JcmsServletFilter
endFilter, initJSONBridge, processFilter
-
-
-
-
Field Detail
-
PROGRESS_STATUS
public static final java.lang.String PROGRESS_STATUS
- See Also:
- Constant Field Values
-
UPLOAD_ERROR
public static final java.lang.String UPLOAD_ERROR
- See Also:
- Constant Field Values
-
UPLOAD_DIR
public static final java.lang.String UPLOAD_DIR
Name of directory, created inside the temporary directory, that will be used to store temporary upload file.- See Also:
- Constant Field Values
-
CACHE_MULTIPART_PATHINFO
public static final java.lang.String CACHE_MULTIPART_PATHINFO
- See Also:
- Constant Field Values
-
config
protected javax.servlet.FilterConfig config
-
directory
protected java.io.File directory
-
sizeThreshold
protected int sizeThreshold
-
sizeMax
protected long sizeMax
-
countMax
protected long countMax
-
initFilter
protected boolean initFilter
-
-
Method Detail
-
init
public void init(javax.servlet.FilterConfig cfg) throws javax.servlet.ServletException
- Specified by:
init
in interfacejavax.servlet.Filter
- Throws:
javax.servlet.ServletException
- See Also:
Filter.init(FilterConfig)
-
initFileUpload
public void initFileUpload() throws javax.servlet.ServletException
Initialise filter's parameter from FilterConfing and JCMS Properties- Throws:
javax.servlet.ServletException
-
doFilter
public void doFilter(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res, javax.servlet.FilterChain chain) throws java.io.IOException, javax.servlet.ServletException
Wraps the ServletRequest into a MultiPart Request if it contains multipart data.- Specified by:
doFilter
in interfacejavax.servlet.Filter
- Throws:
java.io.IOException
javax.servlet.ServletException
- See Also:
Filter.doFilter(ServletRequest, ServletResponse, FilterChain)
-
wrapRequest
protected javax.servlet.http.HttpServletRequest wrapRequest(javax.servlet.http.HttpServletRequest request) throws org.apache.commons.fileupload.FileUploadException, java.io.UnsupportedEncodingException
Wrap the request into a MultipartRequest if we are in MultipartContent with upload- Parameters:
request
- current HttpServletRequest- Returns:
- the given request if it's not a multipart content with upload, or a new instance of MultipartRequest
- Throws:
org.apache.commons.fileupload.FileUploadException
java.io.UnsupportedEncodingException
-
destroy
public void destroy()
- Specified by:
destroy
in interfacejavax.servlet.Filter
- See Also:
Filter.destroy()
-
getFileUploadStatus
public static java.util.Map<java.lang.String,java.lang.String> getFileUploadStatus(java.lang.String field, java.lang.String token)
-
-