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 sub directory UPLOAD_DIR in javax.servlet.context.tempdir 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".
Modifier and Type | Field and Description |
---|---|
protected javax.servlet.FilterConfig |
config |
protected java.io.File |
directory |
protected boolean |
initFilter |
static java.lang.String |
PROGRESS_STATUS |
static java.lang.String |
REVISION |
protected long |
sizeMax |
protected int |
sizeThreshold |
static java.lang.String |
UPLOAD_DIR |
static java.lang.String |
UPLOAD_ERROR |
Constructor and Description |
---|
MultipartFilter() |
Modifier and Type | Method and 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 Properties
|
protected void |
registerJSONClass(javax.servlet.http.HttpServletRequest request)
Register MultipartRequest class in JSON for use by docChooser.js upload status
|
protected javax.servlet.http.HttpServletRequest |
wrapRequest(javax.servlet.http.HttpServletRequest request)
Wrap the request into a MultipartRequest if we are in MultipartContent with upload
|
endFilter, initJSONBridge, processFilter
public static final java.lang.String REVISION
public static final java.lang.String PROGRESS_STATUS
public static final java.lang.String UPLOAD_ERROR
public static final java.lang.String UPLOAD_DIR
protected javax.servlet.FilterConfig config
protected java.io.File directory
protected int sizeThreshold
protected long sizeMax
protected boolean initFilter
public void init(javax.servlet.FilterConfig cfg) throws javax.servlet.ServletException
init
in interface javax.servlet.Filter
javax.servlet.ServletException
Filter.init(FilterConfig)
public void initFileUpload() throws javax.servlet.ServletException
javax.servlet.ServletException
public void doFilter(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res, javax.servlet.FilterChain chain) throws java.io.IOException, javax.servlet.ServletException
doFilter
in interface javax.servlet.Filter
java.io.IOException
javax.servlet.ServletException
Filter.doFilter(ServletRequest, ServletResponse, FilterChain)
protected void registerJSONClass(javax.servlet.http.HttpServletRequest request)
request
- current HttpServletRequestprotected javax.servlet.http.HttpServletRequest wrapRequest(javax.servlet.http.HttpServletRequest request) throws org.apache.commons.fileupload.FileUploadException, java.io.UnsupportedEncodingException
request
- current HttpServletRequestorg.apache.commons.fileupload.FileUploadException
java.io.UnsupportedEncodingException
public void destroy()
destroy
in interface javax.servlet.Filter
Filter.destroy()
public static java.util.Map<java.lang.String,java.lang.String> getFileUploadStatus(java.lang.String field, java.lang.String token)
Copyright © 2001-2010 Jalios SA. All Rights Reserved.