org.apache.struts.upload
public class MultipartIterator extends Object
Deprecated: Use the Commons FileUpload based multipart handler instead. This class will be removed after Struts 1.2.
The MultipartIterator class is responsible for reading the input data of a multipart request and splitting it up into input elements, wrapped inside of a MultipartElement
for easy definition. To use this class, create a new instance
of MultipartIterator passing it a HttpServletRequest in the
constructor. Then use the getNextElement
method until it returns null, then you're finished. Example: MultipartIterator iterator = new MultipartIterator(request); MultipartElement element; while ((element = iterator.getNextElement()) != null) { //do something with element }
Field Summary | |
---|---|
protected String | boundary
The boundary for this multipart request |
protected int | bufferSize
The amount of data read from a request at a time.
|
protected int | contentLength
The content length of this request |
protected String | contentType
The content-type. |
protected int | diskBufferSize
The size in bytes written to the filesystem at a time [20K] |
static String | DEFAULT_ENCODING
The default encoding of a text element if none is specified. |
static String | FILE_PREFIX |
static String | HEADER_CONTENT_DISPOSITION
The name of the Content-Disposition header. |
static String | HEADER_CONTENT_TYPE
The name of the Content-Type header. |
protected MultipartBoundaryInputStream | inputStream
The InputStream to use to read the multipart data. |
protected boolean | maxLengthExceeded
Whether the maximum length has been exceeded. |
protected long | maxSize
The maximum file size in bytes allowed. |
static String | MESSAGE_CANNOT_RETRIEVE_BOUNDARY
The exception message for when the boundary of a multipart request can't be determined. |
static String | PARAMETER_BOUNDARY |
protected HttpServletRequest | request
The request instance for this class |
protected String | tempDir
The temporary directory to store files |
static int | TEXT_BUFFER_SIZE
The size in bytes to copy of text data at a time. |
Constructor Summary | |
---|---|
MultipartIterator(HttpServletRequest request)
Constructs a MultipartIterator with a default buffer size and no file size
limit
| |
MultipartIterator(HttpServletRequest request, int bufferSize)
Constructs a MultipartIterator with the specified buffer size and
no file size limit
| |
MultipartIterator(HttpServletRequest request, int bufferSize, long maxSize)
Constructs a MultipartIterator with the specified buffer size and
the specified file size limit in bytes
| |
MultipartIterator(HttpServletRequest request, int bufferSize, long maxSize, String tempDir) |
Method Summary | |
---|---|
protected MultipartElement | createFileMultipartElement()
Create a multipart element instance representing the file in the stream. |
protected File | createLocalFile()
Creates a file on disk from the current mulitpart element. |
protected MultipartElement | createTextMultipartElement(String encoding)
Create a text element from the data in the body of the element. |
void | getBoundaryFromContentType()
Parses a content-type String for the boundary. |
int | getBufferSize()
Get the maximum amount of bytes read from a line at one time
|
void | getContentTypeOfRequest()
Gets the value of the Content-Type header of the request. |
protected String | getElementEncoding()
Get the character encoding used for this current multipart element. |
long | getMaxSize()
Get the maximum post data size allowed for a multipart request |
MultipartElement | getNextElement()
Retrieves the next element in the iterator if one exists.
|
boolean | isMaxLengthExceeded()
Whether or not the maximum length has been exceeded by the client. |
protected void | parseRequest()
Handles retrieving the boundary and setting the input stream |
void | setBufferSize(int bufferSize)
Set the maximum amount of bytes read from a line at one time
|
void | setMaxSize(long maxSize)
Set the maximum post data size allowed for a multipart request |
Parameters: request The multipart request to iterate
Parameters: request The multipart request to iterate bufferSize The size in bytes that should be read from the input stream at a times
Parameters: request The multipart request to iterate bufferSize The size in bytes that should be read from the input stream at a times maxSize The maximum size in bytes allowed for a multipart element's data
Parameters: encoding The character encoding of the string.
See Also: javax.servlet.ServletInputStream#readLine(byte[], int, int)
Returns: The maximum post data size in bytes
Returns: a MultipartElement
representing the next element in the request data
Throws: IOException if the post size exceeds the maximum file size passed in the 3 argument constructor or if the "ISO-8859-1" encoding isn't found
See Also: javax.servlet.ServletInputStream#readLine(byte[], int, int)
Parameters: maxSize The maximum post data size in bytes, set to -1
for no limit