public interface IFileItemStream extends IFileItemHeadersSupport
This interface 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 openStream().
Instances of this class are created by accessing the iterator, returned by
AbstractFileUploadBase.getItemIterator(IRequestContext)
.
Note: There is an interaction between the iterator and its
associated instances of IFileItemStream: By invoking
Iterator.hasNext() on the iterator, you discard all data,
which hasn't been read so far from the previous data.
| Modifier and Type | Method and Description |
|---|---|
String |
getContentType()
Returns the content type passed by the browser or
null if not
defined. |
String |
getFieldName()
Returns the name of the field in the multipart form corresponding to this
file item.
|
String |
getName()
Returns the original filename in the client's filesystem, as provided by
the browser (or other client software).
|
String |
getNameSecure()
Returns the original filename in the client's filesystem, as provided by
the browser (or other client software).
|
String |
getNameUnchecked()
Returns the original filename in the client's filesystem, as provided by
the browser (or other client software).
|
boolean |
isFormField()
Determines whether or not a
FileItem instance represents a
simple form field. |
InputStream |
openStream()
Creates an
InputStream, which allows to read the items contents. |
getHeaders, setHeadersInputStream openStream() throws IOException
InputStream, which allows to read the items contents.IllegalStateException - The method was already invoked on this item. It is not possible to
recreate the data stream.IOException - An I/O error occurred.String getContentType()
null if not
defined.null if not
defined.String getName()
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().String getNameSecure()
getName() this method automatically removes everything and
including a NUL byte and therefore does not throw an
InvalidFileNameException.@Nullable String getNameUnchecked()
String getFieldName()
boolean isFormField()
FileItem instance represents a
simple form field.true if the instance represents a simple form field;
false if it represents an uploaded file.Copyright © 2014–2019 Philip Helger. All rights reserved.