public class HttpMultipart
extends java.lang.Object
a) The O'reilly class does not guarantee order upon retrieval (i.e., getParameterNames() and getFileNames() invoke Hashtable.keys(), which returns keys in the reverse order of addition). b) It fixes a bug related to the order in which the headers are present. The headers can be present in any order, instead of a specific order. c) Stores any user-defined headers in each individual part of the muti-part data d) It uses better data structures like HashMap and Iterator instead of Hashtable and Enumeration.
Constructor and Description |
---|
HttpMultipart(javax.servlet.ServletRequest request,
java.lang.String saveDirectory)
Constructs a new HttpMultipart to handle the specified request,
saving any uploaded files to the given directory, and limiting the
upload size to 2 MB.
|
HttpMultipart(javax.servlet.ServletRequest request,
java.lang.String saveDirectory,
int maxPostSize)
Constructs a new HttpMultipart to handle the specified request,
saving any uploaded files to the given directory, and limiting the
upload size to the specified length.
|
Modifier and Type | Method and Description |
---|---|
void |
deleteAllUploadedFiles()
Delete all the uploaded files.
|
java.lang.String |
getContentType(java.lang.String name)
Returns the content type of the specified file (as supplied by the
client browser), or null if the file was not included in the upload.
|
java.io.File |
getFile(java.lang.String name)
Returns a File object for the specified file saved on the server's
filesystem, or null if the file was not included in the upload.
|
java.util.Iterator |
getFileNames()
Returns the names of all the uploaded files as an Iterator of
Strings.
|
java.lang.String |
getFilesystemName(java.lang.String name)
Returns the filesystem name of the specified file, or null if the
file was not included in the upload.
|
java.util.Map |
getHeaders(java.lang.String name)
Returns the user-defined headers associated with each individual part
of the multi-part request
|
java.util.List |
getListFileName()
getListFileName - Get list of file names
|
java.util.List |
getListParameterName()
getListParameterName - Get list of parameter names
|
java.lang.String |
getParameter(java.lang.String name)
Returns the value of the named parameter as a String, or null if
the parameter was not given.
|
java.util.Iterator |
getParameterNames()
Returns the names of all the parameters as an Iterator of
Strings.
|
public HttpMultipart(javax.servlet.ServletRequest request, java.lang.String saveDirectory) throws java.io.IOException
request
- the servlet requestsaveDirectory
- the directory in which to save any uploaded filesjava.io.IOException
- if the uploaded content is larger than 1 Megabyte
or there's a problem reading or parsing the requestpublic HttpMultipart(javax.servlet.ServletRequest request, java.lang.String saveDirectory, int maxPostSize) throws java.io.IOException
request
- the servlet requestsaveDirectory
- the directory in which to save any uploaded filesmaxPostSize
- the maximum size of the POST contentjava.io.IOException
- if the uploaded content is larger than
maxPostSize or there's a problem reading or parsing the requestpublic java.util.List getListParameterName() throws java.lang.Exception
None
- java.lang.Exception
public java.util.List getListFileName() throws java.lang.Exception
None
- java.lang.Exception
public java.util.Iterator getParameterNames()
public java.util.Iterator getFileNames()
public java.lang.String getParameter(java.lang.String name)
name
- the parameter namepublic java.lang.String getFilesystemName(java.lang.String name)
name
- the file namepublic java.lang.String getContentType(java.lang.String name)
name
- the file namepublic java.io.File getFile(java.lang.String name)
name
- the file namepublic java.util.Map getHeaders(java.lang.String name)
public void deleteAllUploadedFiles()