Interface FileItemInput
- All Superinterfaces:
FileItemHeadersProvider<FileItemInput>
Provides access to a file or form item that was received within a
multipart/form-data POST request.
The items contents are retrieved by calling getInputStream().
Instances of this class are created by accessing the iterator, returned by AbstractFileUpload.getItemIterator(RequestContext).
Note: There is an interaction between the iterator and its associated instances of FileItemInput: By invoking
Iterator.hasNext() on the iterator, you discard all data, which hasn't been read so far from the previous data.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classThis exception is thrown, if an attempt is made to read data from theInputStream, which has been returned bygetInputStream(), afterIterator.hasNext()has been invoked on the iterator, which created theFileItemInput. -
Method Summary
Modifier and TypeMethodDescriptionGets the content type passed by the browser ornullif not defined.Gets the name of the field in the multipart form corresponding to this file item.Opens anInputStream, which allows to read the items contents.getName()Gets the original file name in the client's file system, as provided by the browser (or other client software).booleanTests whether or not aFileIteminstance represents a simple form field.Methods inherited from interface org.apache.commons.fileupload2.core.FileItemHeadersProvider
getHeaders, setHeaders
-
Method Details
-
getContentType
Gets the content type passed by the browser ornullif not defined.- Returns:
- The content type passed by the browser or
nullif not defined.
-
getFieldName
Gets the name of the field in the multipart form corresponding to this file item.- Returns:
- The name of the form field.
-
getInputStream
Opens anInputStream, which allows to read the items contents.- Returns:
- The input stream, from which the items data may be read.
- Throws:
IllegalStateException- The method was already invoked on this item. It is not possible to recreate the data stream.IOException- An I/O error occurred.- See Also:
-
getName
Gets the original file name in the client's file system, as provided by the browser (or other client software). In most cases, this will be the base file name, without path information. However, some clients, such as the Opera browser, do include path information.- Returns:
- The original file name in the client's file system.
-
isFormField
boolean isFormField()Tests whether or not aFileIteminstance represents a simple form field.- Returns:
trueif the instance represents a simple form field;falseif it represents an uploaded file.
-