HDIV API 2.0.4

org.hdiv.config.multipart
Interface IMultipartConfig

All Known Implementing Classes:
AbstractMultipartConfig, SpringMVCMultipartConfig, Struts2MultipartConfig, StrutsMultipartConfig

public interface IMultipartConfig

Class containing multipart request configuration and methods initialized from Spring Factory.

Author:
Gorka Vicente

Field Summary
static java.lang.String ATTRIBUTE_MAX_LENGTH_EXCEEDED
          This is the ServletRequest attribute that should be set when a multipart request is being read and the maximum length is exceeded.
static long DEFAULT_SIZE_MAX
          The default value for the maximum allowable size, in bytes, of an uploaded file.
static int DEFAULT_SIZE_THRESHOLD
          The default value for the threshold which determines whether an uploaded file will be written to disk or cached in memory.
static java.lang.String FILEUPLOAD_EXCEPTION
          This is the ServletRequest attribute that should be set when a multipart request is being read and failed.
 
Method Summary
 void addFileParameter(RequestWrapper request, org.apache.commons.fileupload.FileItem item)
          Adds a file parameter to the set of file parameters for this request and also to the list of all parameters.
 void addTextParameter(RequestWrapper request, org.apache.commons.fileupload.FileItem item)
          Adds a regular text parameter to the set of text parameters for this request.
 java.lang.String getRepositoryPath(javax.servlet.ServletContext servletContext)
          Returns the path to the temporary directory to be used for uploaded files which are written to disk.
 void handleMultipartRequest(RequestWrapper request, javax.servlet.ServletContext servletContext)
          Parses the input stream and partitions the parsed items into a set of form fields and a set of file items.
 

Field Detail

DEFAULT_SIZE_MAX

static final long DEFAULT_SIZE_MAX
The default value for the maximum allowable size, in bytes, of an uploaded file. The value is equivalent to 2MB.

See Also:
Constant Field Values

DEFAULT_SIZE_THRESHOLD

static final int DEFAULT_SIZE_THRESHOLD
The default value for the threshold which determines whether an uploaded file will be written to disk or cached in memory. The value is equivalent to 250KB.

See Also:
Constant Field Values

ATTRIBUTE_MAX_LENGTH_EXCEEDED

static final java.lang.String ATTRIBUTE_MAX_LENGTH_EXCEEDED
This is the ServletRequest attribute that should be set when a multipart request is being read and the maximum length is exceeded. The value is a Boolean. If the maximum length isn't exceeded, this attribute shouldn't be put in the ServletRequest. It's the job of the implementation to put this attribute in the request if the maximum length is exceeded; in the handleRequest(HttpServletRequest) method.

See Also:
Constant Field Values

FILEUPLOAD_EXCEPTION

static final java.lang.String FILEUPLOAD_EXCEPTION
This is the ServletRequest attribute that should be set when a multipart request is being read and failed. It's the job of the implementation to put this attribute in the request if multipart process failed; in the handleRequest(HttpServletRequest) method.

Since:
HDIV 2.0.1
See Also:
Constant Field Values
Method Detail

handleMultipartRequest

void handleMultipartRequest(RequestWrapper request,
                            javax.servlet.ServletContext servletContext)
                            throws org.apache.commons.fileupload.FileUploadException,
                                   org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException,
                                   org.springframework.web.multipart.MaxUploadSizeExceededException
Parses the input stream and partitions the parsed items into a set of form fields and a set of file items.

Parameters:
request - The multipart request wrapper.
servletContext - Our ServletContext object
Throws:
org.apache.commons.fileupload.FileUploadException - if an unrecoverable error occurs.
DiskFileUpload.SizeLimitExceededException - if size limit exceeded
org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException
org.springframework.web.multipart.MaxUploadSizeExceededException

getRepositoryPath

java.lang.String getRepositoryPath(javax.servlet.ServletContext servletContext)
Returns the path to the temporary directory to be used for uploaded files which are written to disk. The directory used is determined from the first of the following to be non-empty.
  1. A temp dir explicitly defined using the saveDir attribute of the <multipartConfig> element in the Spring config file.
  2. The temp dir specified by the javax.servlet.context.tempdir attribute.

Parameters:
servletContext - servlet context
Returns:
The path to the directory to be used to store uploaded files.

addFileParameter

void addFileParameter(RequestWrapper request,
                      org.apache.commons.fileupload.FileItem item)
Adds a file parameter to the set of file parameters for this request and also to the list of all parameters.

Parameters:
request - The request in which the parameter was specified.
item - The file item for the parameter to add.

addTextParameter

void addTextParameter(RequestWrapper request,
                      org.apache.commons.fileupload.FileItem item)
Adds a regular text parameter to the set of text parameters for this request. Handles the case of multiple values for the same parameter by using an array for the parameter value.

Parameters:
request - The request in which the parameter was specified.
item - The file item for the parameter to add.

HDIV 2.0.4

Copyright © 2008 hdiv.org. All Rights Reserved.