org.apache.commons.fileupload.FileUploadBase Class Reference

Inheritance diagram for org.apache.commons.fileupload.FileUploadBase:

org.apache.commons.fileupload.DiskFileUpload org.apache.commons.fileupload.FileUpload

List of all members.


Detailed Description

High level API for processing file uploads.

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.

Author:
Rafal Krzewski

Daniel Rall

Jason van Zyl

John McNally

Martin Cooper

Sean C. Sullivan

Version:
Id
FileUploadBase.java,v 1.3 2003/06/01 00:18:13 martinc Exp

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.

Member Function Documentation

static final boolean org.apache.commons.fileupload.FileUploadBase.isMultipartContent ( HttpServletRequest  req  )  [static]

Utility method that determines whether the request contains multipart content.

Parameters:
req The servlet request to be evaluated. Must be non-null.
Returns:
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.

Returns:
The factory class for new 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.

Parameters:
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.

Returns:
The maximum allowed size, in bytes.
See also:
setSizeMax(long)

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.

Parameters:
sizeMax The maximum allowed size, in bytes, or -1 for no maximum.
See also:
getSizeMax()

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.

Returns:
The encoding used to read part headers.

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.

Parameters:
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().

Parameters:
req The servlet request to be parsed.
Returns:
A list of FileItem instances parsed from the request, in the order that they were transmitted.
Exceptions:
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.

Parameters:
headers A Map containing the HTTP request headers.
Returns:
The file name for the current 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.

Parameters:
headers A Map containing the HTTP request headers.
Returns:
The field name for the current 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.

Parameters:
headers A Map containing the HTTP request headers.
isFormField Whether or not this item is a form field, as opposed to a file.
Returns:
A newly created FileItem instance.
Exceptions:
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.

Parameters:
headerPart The header-part of the current encapsulation.
Returns:
A 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.

Parameters:
headers A Map containing the HTTP request headers.
name The name of the header to return.
Returns:
The value of specified header, or a comma-separated list if there were multiple headers of that name.

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().


The documentation for this class was generated from the following file:
Generated on Mon Jan 11 21:19:18 2010 for OpenMobileIS by  doxygen 1.5.4