Package org.apache.commons.fileupload
Class FileUploadBase.FileItemIteratorImpl.FileItemStreamImpl
java.lang.Object
org.apache.commons.fileupload.FileUploadBase.FileItemIteratorImpl.FileItemStreamImpl
- All Implemented Interfaces:
FileItemHeadersSupport,FileItemStream
- Enclosing class:
FileUploadBase.FileItemIteratorImpl
private final class FileUploadBase.FileItemIteratorImpl.FileItemStreamImpl
extends Object
implements FileItemStream
Default implementation of
FileItemStream.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.commons.fileupload.FileItemStream
FileItemStream.ItemSkippedException -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe file items content type.private final StringThe file items field name.private final booleanWhether the file item is a form field.private FileItemHeadersThe headers, if any.private final InputStreamThe file items input stream.private final StringThe file items file name. -
Constructor Summary
ConstructorsConstructorDescriptionFileItemStreamImpl(String name, String fieldName, String contentType, boolean formField, long contentLength) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescription(package private) voidclose()Closes the file item.Returns the items content type, or null.Returns the items field name.Returns the file item headers.getName()Returns the items file name.booleanReturns, whether this is a form field.Returns an input stream, which may be used to read the items contents.voidsetHeaders(FileItemHeaders headers) Sets the file item headers.
-
Field Details
-
contentType
The file items content type. -
fieldName
The file items field name. -
name
The file items file name. -
formField
private final boolean formFieldWhether the file item is a form field. -
inputStream
The file items input stream. -
headers
The headers, if any.
-
-
Constructor Details
-
FileItemStreamImpl
FileItemStreamImpl(String name, String fieldName, String contentType, boolean formField, long contentLength) throws IOException Creates a new instance.- Parameters:
name- 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.
-
-
Method Details
-
close
Closes the file item.- Throws:
IOException- An I/O error occurred.
-
getContentType
Returns the items content type, or null.- Specified by:
getContentTypein interfaceFileItemStream- Returns:
- Content type, if known, or null.
-
getFieldName
Returns the items field name.- Specified by:
getFieldNamein interfaceFileItemStream- Returns:
- Field name.
-
getHeaders
Returns the file item headers.- Specified by:
getHeadersin interfaceFileItemHeadersSupport- Returns:
- The items header object
-
getName
Returns the items file name.- Specified by:
getNamein interfaceFileItemStream- Returns:
- File name, if known, or null.
- Throws:
InvalidFileNameException- The file name 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 InvalidFileNameException#getName().
-
isFormField
public boolean isFormField()Returns, whether this is a form field.- Specified by:
isFormFieldin interfaceFileItemStream- Returns:
- True, if the item is a form field, otherwise false.
-
openStream
Returns an input stream, which may be used to read the items contents.- Specified by:
openStreamin interfaceFileItemStream- Returns:
- Opened input stream.
- Throws:
IOException- An I/O error occurred.- See Also:
-
setHeaders
Sets the file item headers.- Specified by:
setHeadersin interfaceFileItemHeadersSupport- Parameters:
headers- The items header object
-