Package com.helger.web.fileupload
Interface IFileItemStream
-
- All Superinterfaces:
IFileItemHeadersSupport
- All Known Implementing Classes:
FileItemStream
public interface IFileItemStream extends IFileItemHeadersSupport
This interface provides access to a file or form item that was received within a
multipart/form-dataPOST request. The items contents are retrieved by callingopenStream().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 invokingIterator.hasNext()on the iterator, you discard all data, which hasn't been read so far from the previous data.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringgetContentType()Returns the content type passed by the browser ornullif not defined.StringgetFieldName()Returns the name of the field in the multipart form corresponding to this file item.StringgetName()Returns the original filename in the client's filesystem, as provided by the browser (or other client software).StringgetNameSecure()Returns the original filename in the client's filesystem, as provided by the browser (or other client software).StringgetNameUnchecked()Returns the original filename in the client's filesystem, as provided by the browser (or other client software).booleanisFormField()Determines whether or not aFileIteminstance represents a simple form field.InputStreamopenStream()Creates anInputStream, which allows to read the items contents.-
Methods inherited from interface com.helger.web.fileupload.IFileItemHeadersSupport
getHeaders, setHeaders
-
-
-
-
Method Detail
-
openStream
InputStream openStream() throws IOException
Creates 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.
-
getContentType
String getContentType()
Returns the content type passed by the browser ornullif not defined.- Returns:
- The content type passed by the browser or
nullif not defined.
-
getName
String getName()
Returns the original filename in the client's filesystem, 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 filename in the client's filesystem.
- 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().
-
getNameSecure
String getNameSecure()
Returns the original filename in the client's filesystem, 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. Compared togetName()this method automatically removes everything and including a NUL byte and therefore does not throw anInvalidFileNameException.- Returns:
- The original filename in the client's filesystem.
- Since:
- 6.1.0
-
getNameUnchecked
@Nullable String getNameUnchecked()
Returns the original filename in the client's filesystem, 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 filename in the client's filesystem.
- Since:
- 6.1.0
-
getFieldName
String getFieldName()
Returns the name of the field in the multipart form corresponding to this file item.- Returns:
- The name of the form field.
-
isFormField
boolean isFormField()
Determines whether or not aFileIteminstance represents a simple form field.- Returns:
trueif the instance represents a simple form field;falseif it represents an uploaded file.
-
-