Class FileItemInputImpl
java.lang.Object
org.apache.commons.fileupload2.core.FileItemInputImpl
- All Implemented Interfaces:
FileItemHeadersProvider<FileItemInput>,FileItemInput
Default implementation of
FileItemInput.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.commons.fileupload2.core.FileItemInput
FileItemInput.ItemSkippedException -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe file items content type.private final StringThe file items field name.private final FileItemInputIteratorImplThe File Item iterator implementation.private final StringThe file items file name.private final booleanWhether the file item is a form field.private FileItemHeadersThe headers, if any.private final InputStreamThe file items input stream.private booleanThe file items input stream closed flag. -
Constructor Summary
ConstructorsConstructorDescriptionFileItemInputImpl(FileItemInputIteratorImpl fileItemIterator, String fileName, String fieldName, String contentType, boolean formField, long contentLength) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the file item.Gets the content type, or null.Gets the items field name.Gets the headers.Gets the input stream, which may be used to read the items contents.getName()Gets the file name.booleanTests whether this is a form field.setHeaders(FileItemHeaders headers) Sets the file item headers.
-
Field Details
-
fileItemInputIteratorImpl
The File Item iterator implementation.- See Also:
-
contentType
The file items content type. -
fieldName
The file items field name. -
fileName
The file items file name. -
formField
private final boolean formFieldWhether the file item is a form field. -
inputStream
The file items input stream. -
inputStreamClosed
private boolean inputStreamClosedThe file items input stream closed flag. -
headers
The headers, if any.
-
-
Constructor Details
-
FileItemInputImpl
FileItemInputImpl(FileItemInputIteratorImpl fileItemIterator, String fileName, String fieldName, String contentType, boolean formField, long contentLength) throws FileUploadException, IOException Creates a new instance.- Parameters:
fileItemIterator- Theiterator, which returned this file item.fileName- The items file name, or null.fieldName- The items field name.contentType- The items content type, or null.formField- Whether the item is a form field.contentLength- The items content length, if known, or -1- Throws:
IOException- Creating the file item failed.FileUploadException- Parsing the incoming data stream failed.
-
-
Method Details
-
close
Closes the file item.- Throws:
IOException- An I/O error occurred.
-
getContentType
Gets the content type, or null.- Specified by:
getContentTypein interfaceFileItemInput- Returns:
- Content type, if known, or null.
-
getFieldName
Gets the items field name.- Specified by:
getFieldNamein interfaceFileItemInput- Returns:
- Field name.
-
getHeaders
Gets the headers.- Specified by:
getHeadersin interfaceFileItemHeadersProvider<FileItemInput>- Returns:
- The items header object
-
getInputStream
Gets the input stream, which may be used to read the items contents.- Specified by:
getInputStreamin interfaceFileItemInput- Returns:
- Opened input stream.
- Throws:
IOException- An I/O error occurred.- See Also:
-
getName
Gets the file name.- Specified by:
getNamein interfaceFileItemInput- Returns:
- File name, if known, or null.
- Throws:
InvalidPathException- The file name is invalid, for example it contains a NUL character, which might be an indicator of a security attack. If you intend to use the file name anyways, catch the exception and use InvalidPathException#getInput().
-
isFormField
public boolean isFormField()Tests whether this is a form field.- Specified by:
isFormFieldin interfaceFileItemInput- Returns:
- True, if the item is a form field, otherwise false.
-
setHeaders
Sets the file item headers.- Specified by:
setHeadersin interfaceFileItemHeadersProvider<FileItemInput>- Parameters:
headers- The items header object- Returns:
- this
-