This class handles multiple files per single HTML widget, sent using multipart/mixed
encoding type, as specified by RFC 1867. Use parseRequest(HttpServletRequest) to acquire a list of org.apache.commons.fileupload.FileItems associated with a given HTML widget.
How the data for individual parts is stored is determined by the factory used to create them; a given part may be in memory, on disk, or somewhere else.
Definition at line 99 of file FileUploadBase.java.
Public Member Functions | |
abstract FileItemFactory | getFileItemFactory () |
Returns the factory class used when creating file items. | |
abstract void | setFileItemFactory (FileItemFactory factory) |
Sets the factory class to use when creating file items. | |
long | getSizeMax () |
Returns the maximum allowed upload size. | |
void | setSizeMax (long sizeMax) |
Sets the maximum allowed upload size. | |
String | getHeaderEncoding () |
Retrieves the character encoding used when reading the headers of an individual part. | |
void | setHeaderEncoding (String encoding) |
Specifies the character encoding to be used when reading the headers of individual parts. | |
List | parseRequest (HttpServletRequest req) throws FileUploadException |
Processes an RFC 1867 compliant multipart/form-data stream. | |
Static Public Member Functions | |
static final boolean | isMultipartContent (HttpServletRequest req) |
Utility method that determines whether the request contains multipart content. | |
Static Public Attributes | |
static final String | CONTENT_TYPE = "Content-type" |
HTTP content type header name. | |
static final String | CONTENT_DISPOSITION = "Content-disposition" |
HTTP content disposition header name. | |
static final String | FORM_DATA = "form-data" |
Content-disposition value for form data. | |
static final String | ATTACHMENT = "attachment" |
Content-disposition value for file attachment. | |
static final String | MULTIPART = "multipart/" |
Part of HTTP content type header. | |
static final String | MULTIPART_FORM_DATA = "multipart/form-data" |
HTTP content type header for multipart forms. | |
static final String | MULTIPART_MIXED = "multipart/mixed" |
HTTP content type header for multiple uploads. | |
static final int | MAX_HEADER_SIZE = 1024 |
The maximum length of a single header line that will be parsed (1024 bytes). | |
Protected Member Functions | |
String | getFileName (Mapheaders) |
Retrieves the file name from the Content-disposition header. | |
String | getFieldName (Mapheaders) |
Retrieves the field name from the Content-disposition header. | |
FileItem | createItem (Mapheaders, boolean isFormField) throws FileUploadException |
Creates a new FileItem instance. | |
Map | parseHeaders (String headerPart) |
final String | getHeader (Mapheaders, String name) |
Returns the header with the specified name from the supplied map. | |
Classes | |
class | InvalidContentTypeException |
Thrown to indicate that the request is not a multipart request. | |
class | SizeLimitExceededException |
Thrown to indicate that the request size exceeds the configured maximum. | |
class | UnknownSizeException |
Thrown to indicate that the request size is not specified. |
static final boolean org.apache.commons.fileupload.FileUploadBase.isMultipartContent | ( | HttpServletRequest | req | ) | [static] |
Utility method that determines whether the request contains multipart content.
req | The servlet request to be evaluated. Must be non-null. |
true
if the request is multipart; false
otherwise. Definition at line 114 of file FileUploadBase.java.
References org.apache.commons.fileupload.FileUploadBase.CONTENT_TYPE, and org.apache.commons.fileupload.FileUploadBase.MULTIPART.
abstract FileItemFactory org.apache.commons.fileupload.FileUploadBase.getFileItemFactory | ( | ) | [pure virtual] |
Returns the factory class used when creating file items.
Implemented in org.apache.commons.fileupload.DiskFileUpload, and org.apache.commons.fileupload.FileUpload.
Referenced by org.apache.commons.fileupload.FileUploadBase.createItem().
abstract void org.apache.commons.fileupload.FileUploadBase.setFileItemFactory | ( | FileItemFactory | factory | ) | [pure virtual] |
Sets the factory class to use when creating file items.
factory | The factory class for new file items. |
Implemented in org.apache.commons.fileupload.DiskFileUpload, and org.apache.commons.fileupload.FileUpload.
long org.apache.commons.fileupload.FileUploadBase.getSizeMax | ( | ) |
Returns the maximum allowed upload size.
Definition at line 224 of file FileUploadBase.java.
void org.apache.commons.fileupload.FileUploadBase.setSizeMax | ( | long | sizeMax | ) |
Sets the maximum allowed upload size.
If negative, there is no maximum.
sizeMax | The maximum allowed size, in bytes, or -1 for no maximum. |
Definition at line 238 of file FileUploadBase.java.
Referenced by org.apache.commons.fileupload.DiskFileUpload.parseRequest().
String org.apache.commons.fileupload.FileUploadBase.getHeaderEncoding | ( | ) |
Retrieves the character encoding used when reading the headers of an individual part.
When not specified, or null
, the platform default encoding is used.
Definition at line 251 of file FileUploadBase.java.
void org.apache.commons.fileupload.FileUploadBase.setHeaderEncoding | ( | String | encoding | ) |
Specifies the character encoding to be used when reading the headers of individual parts.
When not specified, or null
, the platform default encoding is used.
encoding | The encoding used to read part headers. |
Definition at line 264 of file FileUploadBase.java.
List org.apache.commons.fileupload.FileUploadBase.parseRequest | ( | HttpServletRequest | req | ) | throws FileUploadException |
Processes an RFC 1867 compliant multipart/form-data
stream.
If files are stored on disk, the path is given by getRepository()
.
req | The servlet request to be parsed. |
FileItem
instances parsed from the request, in the order that they were transmitted.FileUploadException | if there are problems reading/parsing the request or storing files. |
Definition at line 286 of file FileUploadBase.java.
References org.apache.commons.fileupload.FileUploadBase.CONTENT_TYPE, org.apache.commons.fileupload.FileUploadBase.createItem(), org.apache.commons.fileupload.MultipartStream.discardBodyData(), org.apache.commons.fileupload.FileUploadBase.getFieldName(), org.apache.commons.fileupload.FileUploadBase.getFileName(), org.apache.commons.fileupload.FileUploadBase.getHeader(), org.apache.commons.fileupload.FileItem.getOutputStream(), org.apache.commons.fileupload.FileUploadBase.MULTIPART, org.apache.commons.fileupload.FileUploadBase.MULTIPART_FORM_DATA, org.apache.commons.fileupload.FileUploadBase.MULTIPART_MIXED, org.apache.commons.fileupload.FileUploadBase.parseHeaders(), org.apache.commons.fileupload.MultipartStream.readBodyData(), org.apache.commons.fileupload.MultipartStream.readBoundary(), org.apache.commons.fileupload.MultipartStream.readHeaders(), org.apache.commons.fileupload.MultipartStream.setBoundary(), org.apache.commons.fileupload.MultipartStream.setHeaderEncoding(), and org.apache.commons.fileupload.MultipartStream.skipPreamble().
String org.apache.commons.fileupload.FileUploadBase.getFileName | ( | Map | headers | ) | [protected] |
Retrieves the file name from the Content-disposition
header.
headers | A Map containing the HTTP request headers. |
encapsulation
. Definition at line 449 of file FileUploadBase.java.
References org.apache.commons.fileupload.FileUploadBase.ATTACHMENT, org.apache.commons.fileupload.FileUploadBase.CONTENT_DISPOSITION, org.apache.commons.fileupload.FileUploadBase.FORM_DATA, and org.apache.commons.fileupload.FileUploadBase.getHeader().
Referenced by org.apache.commons.fileupload.FileUploadBase.createItem(), and org.apache.commons.fileupload.FileUploadBase.parseRequest().
String org.apache.commons.fileupload.FileUploadBase.getFieldName | ( | Map | headers | ) | [protected] |
Retrieves the field name from the Content-disposition
header.
headers | A Map containing the HTTP request headers. |
encapsulation
. Definition at line 474 of file FileUploadBase.java.
References org.apache.commons.fileupload.FileUploadBase.CONTENT_DISPOSITION, org.apache.commons.fileupload.FileUploadBase.FORM_DATA, and org.apache.commons.fileupload.FileUploadBase.getHeader().
Referenced by org.apache.commons.fileupload.FileUploadBase.createItem(), and org.apache.commons.fileupload.FileUploadBase.parseRequest().
FileItem org.apache.commons.fileupload.FileUploadBase.createItem | ( | Map | headers, | |
boolean | isFormField | |||
) | throws FileUploadException [protected] |
Creates a new FileItem instance.
headers | A Map containing the HTTP request headers. | |
isFormField | Whether or not this item is a form field, as opposed to a file. |
FileItem
instance.FileUploadException | if an error occurs. |
Definition at line 503 of file FileUploadBase.java.
References org.apache.commons.fileupload.FileUploadBase.CONTENT_TYPE, org.apache.commons.fileupload.FileItemFactory.createItem(), org.apache.commons.fileupload.FileUploadBase.getFieldName(), org.apache.commons.fileupload.FileUploadBase.getFileItemFactory(), org.apache.commons.fileupload.FileUploadBase.getFileName(), and org.apache.commons.fileupload.FileUploadBase.getHeader().
Referenced by org.apache.commons.fileupload.FileUploadBase.parseRequest().
Map org.apache.commons.fileupload.FileUploadBase.parseHeaders | ( | String | headerPart | ) | [protected] |
Parses the header-part
and returns as key/value pairs.
If there are multiple headers of the same names, the name will map to a comma-separated list containing the values.
headerPart | The header-part of the current encapsulation . |
Map
containing the parsed HTTP request headers. Definition at line 526 of file FileUploadBase.java.
References org.apache.commons.fileupload.FileUploadBase.getHeader(), and org.apache.commons.fileupload.FileUploadBase.MAX_HEADER_SIZE.
Referenced by org.apache.commons.fileupload.FileUploadBase.parseRequest().
final String org.apache.commons.fileupload.FileUploadBase.getHeader | ( | Map | headers, | |
String | name | |||
) | [protected] |
Returns the header with the specified name from the supplied map.
The header lookup is case-insensitive.
headers | A Map containing the HTTP request headers. | |
name | The name of the header to return. |
Definition at line 595 of file FileUploadBase.java.
Referenced by org.apache.commons.fileupload.FileUploadBase.createItem(), org.apache.commons.fileupload.FileUploadBase.getFieldName(), org.apache.commons.fileupload.FileUploadBase.getFileName(), org.apache.commons.fileupload.FileUploadBase.parseHeaders(), and org.apache.commons.fileupload.FileUploadBase.parseRequest().