|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.web.multipart.cos.CosMultipartResolver
MultipartResolver implementation for Jason Hunter's COS (com.oreilly.servlet). Works with a COS MultipartRequest underneath.
Provides "maxUploadSize" and "defaultEncoding" settings as bean properties; see respective MultipartRequest constructor parameters for details. Default maximum file size is unlimited; fallback encoding is the platform's default.
CosMultipartHttpServletRequest
,
MultipartRequest
Field Summary | |
protected Log |
logger
|
static String |
MULTIPART_CONTENT_TYPE
|
Constructor Summary | |
CosMultipartResolver()
Constructor for use as bean. |
|
CosMultipartResolver(ServletContext servletContext)
Constructor for standalone usage. |
Method Summary | |
void |
cleanupMultipart(MultipartHttpServletRequest request)
Cleanup any resources used for the multipart handling, like a storage for the uploaded files. |
protected String |
determineEncoding(HttpServletRequest request)
Determine the encoding for the given request. |
protected String |
getDefaultEncoding()
Return the default character encoding to use for parsing requests. |
protected int |
getMaxUploadSize()
Return the maximum allowed size (in bytes) before uploads are refused. |
protected File |
getUploadTempDir()
Return the temporary directory where uploaded files get stored. |
boolean |
isMultipart(HttpServletRequest request)
Determine if the request contains multipart content. |
protected com.oreilly.servlet.MultipartRequest |
newMultipartRequest(HttpServletRequest request)
Create a com.oreilly.servlet.MultipartRequest for the given HTTP request. |
MultipartHttpServletRequest |
resolveMultipart(HttpServletRequest request)
Parse the given HTTP request into multipart files and parameters, and wrap the request inside a MultipartHttpServletRequest object that provides access to file descriptors and makes contained parameters accessible via the standard ServletRequest methods. |
void |
setDefaultEncoding(String defaultEncoding)
Set the default character encoding to use for parsing requests, to be applied to headers of individual parts and to form fields. |
void |
setMaxUploadSize(int maxUploadSize)
Set the maximum allowed size (in bytes) before uploads are refused |
void |
setServletContext(ServletContext servletContext)
Set the ServletContext that this object runs in. |
void |
setUploadTempDir(Resource uploadTempDir)
Set the temporary directory where uploaded files get stored. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String MULTIPART_CONTENT_TYPE
protected final Log logger
Constructor Detail |
public CosMultipartResolver()
setServletContext(javax.servlet.ServletContext)
,
ServletContextAware
,
WebApplicationContext
public CosMultipartResolver(ServletContext servletContext)
servletContext
- the ServletContext to useMethod Detail |
public void setMaxUploadSize(int maxUploadSize)
maxUploadSize
- the maximum file size allowedprotected int getMaxUploadSize()
public void setDefaultEncoding(String defaultEncoding)
If the request specifies a character encoding itself, the request encoding will override this setting. This also allows for generically overriding the character encoding in a filter that invokes the ServletRequest.setCharacterEncoding method.
defaultEncoding
- the character encoding to usedetermineEncoding(javax.servlet.http.HttpServletRequest)
,
ServletRequest.getCharacterEncoding()
,
ServletRequest.setCharacterEncoding(java.lang.String)
,
WebUtils.DEFAULT_CHARACTER_ENCODING
protected String getDefaultEncoding()
public void setUploadTempDir(Resource uploadTempDir) throws IOException
IOException
WebUtils.TEMP_DIR_CONTEXT_ATTRIBUTE
protected File getUploadTempDir()
public void setServletContext(ServletContext servletContext)
ServletContextAware
Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method. Invoked after ApplicationContextAware's setApplicationContext.
setServletContext
in interface ServletContextAware
servletContext
- ServletContext object to be used by this objectpublic boolean isMultipart(HttpServletRequest request)
MultipartResolver
Will typically check for content type "multipart/form-data", but the actually accepted requests might depend on the capabilities of the resolver implementation.
isMultipart
in interface MultipartResolver
request
- the servlet request to be evaluated
public MultipartHttpServletRequest resolveMultipart(HttpServletRequest request) throws MultipartException
MultipartResolver
resolveMultipart
in interface MultipartResolver
request
- the servlet request to wrap (must be of a multipart content type)
MultipartException
- if the servlet request is not multipart, or if
implementation-specific problems are encountered (such as exceeding file size limits)MultipartHttpServletRequest.getFile(java.lang.String)
,
MultipartHttpServletRequest.getFileNames()
,
MultipartHttpServletRequest.getFileMap()
,
ServletRequest.getParameter(java.lang.String)
,
ServletRequest.getParameterNames()
,
ServletRequest.getParameterMap()
protected com.oreilly.servlet.MultipartRequest newMultipartRequest(HttpServletRequest request) throws IOException
request
- current HTTP request
IOException
- if thrown by the MultipartRequest constructorprotected String determineEncoding(HttpServletRequest request)
The default implementation checks the request encoding, falling back to the default encoding specified for this resolver.
request
- current HTTP request
ServletRequest.getCharacterEncoding()
,
setDefaultEncoding(java.lang.String)
public void cleanupMultipart(MultipartHttpServletRequest request)
MultipartResolver
cleanupMultipart
in interface MultipartResolver
request
- the request to cleanup resources for
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |