Package com.helger.web.fileupload.parse
Class FileItemStream
- java.lang.Object
-
- com.helger.web.fileupload.parse.FileItemStream
-
- All Implemented Interfaces:
IFileItemHeadersSupport,IFileItemStream,Closeable,AutoCloseable
@NotThreadSafe public class FileItemStream extends Object implements IFileItemStream, Closeable
Default implementation ofIFileItemStream.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the file item.StringgetContentType()Returns the items content type, or null.StringgetFieldName()Returns the items field name.IFileItemHeadersgetHeaders()Returns the collection of headers defined locally within this 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()Returns, whether this is a form field.InputStreamopenStream()Returns an input stream, which may be used to read the items contents.voidsetHeaders(IFileItemHeaders aHeaders)Sets the headers read from within an item.
-
-
-
Method Detail
-
close
public void close() throws IOExceptionCloses the file item.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- An I/O error occurred.
-
getContentType
@Nullable public String getContentType()
Returns the items content type, or null.- Specified by:
getContentTypein interfaceIFileItemStream- Returns:
- Content type, if known, or null.
-
getFieldName
public String getFieldName()
Returns the items field name.- Specified by:
getFieldNamein interfaceIFileItemStream- Returns:
- Field name.
-
getName
@Nullable public String getName()
Description copied from interface:IFileItemStreamReturns 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.- Specified by:
getNamein interfaceIFileItemStream- Returns:
- The original filename in the client's filesystem.
-
getNameSecure
@Nullable public String getNameSecure()
Description copied from interface:IFileItemStreamReturns 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 toIFileItemStream.getName()this method automatically removes everything and including a NUL byte and therefore does not throw anInvalidFileNameException.- Specified by:
getNameSecurein interfaceIFileItemStream- Returns:
- The original filename in the client's filesystem.
-
getNameUnchecked
@Nullable public String getNameUnchecked()
Description copied from interface:IFileItemStreamReturns 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.- Specified by:
getNameUncheckedin interfaceIFileItemStream- Returns:
- The original filename in the client's filesystem.
-
isFormField
public boolean isFormField()
Returns, whether this is a form field.- Specified by:
isFormFieldin interfaceIFileItemStream- Returns:
- True, if the item is a form field, otherwise false.
-
openStream
@Nonnull public InputStream openStream() throws IOException
Returns an input stream, which may be used to read the items contents.- Specified by:
openStreamin interfaceIFileItemStream- Returns:
- Opened input stream.
- Throws:
IOException- An I/O error occurred.
-
getHeaders
@Nullable public IFileItemHeaders getHeaders()
Description copied from interface:IFileItemHeadersSupportReturns the collection of headers defined locally within this item.- Specified by:
getHeadersin interfaceIFileItemHeadersSupport- Returns:
- the
IFileItemHeaderspresent for this item.
-
setHeaders
public void setHeaders(@Nullable IFileItemHeaders aHeaders)
Description copied from interface:IFileItemHeadersSupportSets the headers read from within an item. Implementations ofIFileItemorIFileItemStreamshould implement this interface to be able to get the raw headers found within the item header block.- Specified by:
setHeadersin interfaceIFileItemHeadersSupport- Parameters:
aHeaders- the instance that holds onto the headers for this instance.
-
-