Class FileItemInputIteratorImpl
java.lang.Object
org.apache.commons.fileupload2.core.FileItemInputIteratorImpl
- All Implemented Interfaces:
FileItemInputIterator,org.apache.commons.io.function.IOIterator<FileItemInput>
The iterator returned by
AbstractFileUpload.getItemIterator(RequestContext).-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringThe current items field name.private FileItemInputImplThe item, which we currently process.private booleanWhether we have seen the end of the file.private longThe maximum allowed size of a single uploaded file.private final AbstractFileUpload<?,?, ?> The file uploads processing utility.private booleanWhether the current item may still be read.private byte[]The boundary, which separates the various parts.private MultipartInputThe multi part stream to process.private MultipartInput.ProgressNotifierThe notifier, which used for triggering theProgressListener.private final RequestContextThe request context.private longThe maximum allowed size of a complete request.private booleanWhether we are currently skipping the preamble. -
Constructor Summary
ConstructorsConstructorDescriptionFileItemInputIteratorImpl(AbstractFileUpload<?, ?, ?> fileUploadBase, RequestContext requestContext) Constructs a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanFinds the next item, if any.private longgetContentLength(FileItemHeaders headers) longGets the maximum size of a single file.longGets the maximum size of the complete HTTP request.booleanhasNext()Tests whether another instance ofFileItemInputis available.protected voidinit(AbstractFileUpload<?, ?, ?> fileUploadBase, RequestContext initContext) next()Returns the next availableFileItemInput.voidsetFileSizeMax(long fileSizeMax) Sets the maximum size of a single file.voidsetSizeMax(long sizeMax) Sets the maximum size of the complete HTTP request.unwrap()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.io.function.IOIterator
asIterator, forEachRemaining, remove
-
Field Details
-
fileUpload
The file uploads processing utility.- See Also:
-
requestContext
The request context.- See Also:
-
sizeMax
private long sizeMaxThe maximum allowed size of a complete request. -
fileSizeMax
private long fileSizeMaxThe maximum allowed size of a single uploaded file. -
multiPartInput
The multi part stream to process. -
progressNotifier
The notifier, which used for triggering theProgressListener. -
multiPartBoundary
private byte[] multiPartBoundaryThe boundary, which separates the various parts. -
currentItem
The item, which we currently process. -
currentFieldName
The current items field name. -
skipPreamble
private boolean skipPreambleWhether we are currently skipping the preamble. -
itemValid
private boolean itemValidWhether the current item may still be read. -
eof
private boolean eofWhether we have seen the end of the file.
-
-
Constructor Details
-
FileItemInputIteratorImpl
FileItemInputIteratorImpl(AbstractFileUpload<?, ?, throws FileUploadException, IOException?> fileUploadBase, RequestContext requestContext) Constructs a new instance.- Parameters:
fileUploadBase- Main processor.requestContext- The request context.- Throws:
FileUploadException- An error occurred while parsing the request.IOException- An I/O error occurred.
-
-
Method Details
-
findNextItem
Finds the next item, if any.- Returns:
- True, if an next item was found, otherwise false.
- Throws:
IOException- An I/O error occurred.FileUploadException
-
getContentLength
-
getFileSizeMax
public long getFileSizeMax()Description copied from interface:FileItemInputIteratorGets the maximum size of a single file. AnFileUploadByteCountLimitExceptionwill be thrown, if there is an uploaded file, which is exceeding this value. By default, this value will be copied from theFileUploadBaseobject, however, the user may replace the default value with a request specific value by invokingFileItemInputIterator.setFileSizeMax(long)on this object.- Specified by:
getFileSizeMaxin interfaceFileItemInputIterator- Returns:
- The maximum size of a single, uploaded file. The value -1 indicates "unlimited".
-
getMultiPartInput
- Throws:
FileUploadExceptionIOException
-
getSizeMax
public long getSizeMax()Description copied from interface:FileItemInputIteratorGets the maximum size of the complete HTTP request. ASizeLimitExceededExceptionwill be thrown, if the HTTP request will exceed this value. By default, this value will be copied from theFileUploadBaseobject, however, the user may replace the default value with a request specific value by invokingFileItemInputIterator.setSizeMax(long)on this object.- Specified by:
getSizeMaxin interfaceFileItemInputIterator- Returns:
- The maximum size of the complete HTTP request. The value -1 indicates "unlimited".
-
hasNext
Tests whether another instance ofFileItemInputis available.- Specified by:
hasNextin interfaceFileItemInputIterator- Specified by:
hasNextin interfaceorg.apache.commons.io.function.IOIterator<FileItemInput>- Returns:
- True, if one or more additional file items are available, otherwise false.
- Throws:
FileUploadException- Parsing or processing the file item failed.IOException- Reading the file item failed.
-
init
protected void init(AbstractFileUpload<?, ?, throws FileUploadException, IOException?> fileUploadBase, RequestContext initContext) - Throws:
FileUploadExceptionIOException
-
next
Returns the next availableFileItemInput.- Specified by:
nextin interfaceFileItemInputIterator- Specified by:
nextin interfaceorg.apache.commons.io.function.IOIterator<FileItemInput>- Returns:
- FileItemInput instance, which provides access to the next file item.
- Throws:
NoSuchElementException- No more items are available. UsehasNext()to prevent this exception.FileUploadException- Parsing or processing the file item failed.IOException- Reading the file item failed.
-
setFileSizeMax
public void setFileSizeMax(long fileSizeMax) Description copied from interface:FileItemInputIteratorSets the maximum size of a single file. AnFileUploadByteCountLimitExceptionwill be thrown, if there is an uploaded file, which is exceeding this value. By default, this value will be copied from theFileUploadBaseobject, however, the user may replace the default value with a request specific value by invokingFileItemInputIterator.setFileSizeMax(long)on this object, so there is no need to configure it here.Note: Changing this value doesn't affect files, that have already been uploaded.
- Specified by:
setFileSizeMaxin interfaceFileItemInputIterator- Parameters:
fileSizeMax- The maximum size of a single, uploaded file. The value -1 indicates "unlimited".
-
setSizeMax
public void setSizeMax(long sizeMax) Description copied from interface:FileItemInputIteratorSets the maximum size of the complete HTTP request. ASizeLimitExceededExceptionwill be thrown, if the HTTP request will exceed this value. By default, this value will be copied from theFileUploadBaseobject, however, the user may replace the default value with a request specific value by invokingFileItemInputIterator.setSizeMax(long)on this object.Note: Setting the maximum size on this object will work only, if the iterator is not yet initialized. In other words: If the methods
FileItemInputIterator.hasNext(),FileItemInputIterator.next()have not yet been invoked.- Specified by:
setSizeMaxin interfaceFileItemInputIterator- Parameters:
sizeMax- The maximum size of the complete HTTP request. The value -1 indicates "unlimited".
-
unwrap
- Specified by:
unwrapin interfaceorg.apache.commons.io.function.IOIterator<FileItemInput>
-