public abstract class AbstractFileUploadBase extends Object
High level API for processing file uploads.
This class handles multiple files per single HTML widget, sent using
multipart/mixed encoding type, as specified by
RFC 1867.
How the data for individual parts is stored is determined by the factory used to create them; a given part may be in memory, on disk, or somewhere else.
| Constructor and Description |
|---|
AbstractFileUploadBase() |
| Modifier and Type | Method and Description |
|---|---|
protected FileItemHeaders |
createFileItemHeaders()
Creates a new instance of
IFileItemHeaders. |
protected byte[] |
getBoundary(String sContentType)
Retrieves the boundary from the
Content-type header. |
protected String |
getFieldName(IFileItemHeaders aFileItemHeaders)
Retrieves the field name from the
Content-disposition header. |
abstract IFileItemFactory |
getFileItemFactory()
Returns the factory class used when creating file items.
|
protected String |
getFileName(IFileItemHeaders aHeaders)
Retrieves the file name from the
Content-disposition header. |
long |
getFileSizeMax()
Returns the maximum allowed size of a single uploaded file, as opposed to
getSizeMax(). |
String |
getHeaderEncoding()
Retrieves the character encoding used when reading the headers of an
individual part.
|
IFileItemIterator |
getItemIterator(IRequestContext aCtx)
Processes an RFC 1867
compliant
multipart/form-data stream. |
protected IFileItemHeaders |
getParsedHeaders(String sHeaderPart)
Parses the
header-part and returns as key/value pairs. |
IProgressListener |
getProgressListener()
Returns the progress listener.
|
long |
getSizeMax()
Returns the maximum allowed size of a complete request, as opposed to
getFileSizeMax(). |
com.helger.commons.collection.impl.ICommonsList<IFileItem> |
parseRequest(IRequestContext aCtx)
Processes an RFC 1867
compliant
multipart/form-data stream. |
void |
setFileSizeMax(long nFileSizeMax)
Sets the maximum allowed size of a single uploaded file, as opposed to
getSizeMax(). |
void |
setHeaderEncoding(String sHeaderEncoding)
Specifies the character encoding to be used when reading the headers of
individual part.
|
void |
setProgressListener(IProgressListener aListener)
Sets the progress listener.
|
void |
setSizeMax(long nSizeMax)
Sets the maximum allowed size of a complete request, as opposed to
setFileSizeMax(long). |
@Nonnull public abstract IFileItemFactory getFileItemFactory()
@CheckForSigned public long getSizeMax()
getFileSizeMax().setSizeMax(long)public void setSizeMax(long nSizeMax)
setFileSizeMax(long).nSizeMax - The maximum allowed size, in bytes. The default value of -1
indicates, that there is no limit.getSizeMax()@CheckForSigned public long getFileSizeMax()
getSizeMax().setFileSizeMax(long)public void setFileSizeMax(long nFileSizeMax)
getSizeMax().nFileSizeMax - Maximum size of a single uploaded file.getFileSizeMax()@Nullable public String getHeaderEncoding()
null, the request
encoding is used. If that is also not specified, or null, the
platform default encoding is used.public void setHeaderEncoding(@Nullable String sHeaderEncoding)
null, the request
encoding is used. If that is also not specified, or null, the
platform default encoding is used.sHeaderEncoding - The encoding used to read part headers.@Nullable public IProgressListener getProgressListener()
null.public void setProgressListener(@Nullable IProgressListener aListener)
aListener - The progress listener, if any. May be to null.@Nonnull public IFileItemIterator getItemIterator(@Nonnull IRequestContext aCtx) throws FileUploadException, IOException
multipart/form-data stream.aCtx - The context for the request to be parsed.FileItemStream parsed from
the request, in the order that they were transmitted.FileUploadException - if there are problems reading/parsing the request or storing files.IOException - An I/O error occurred. This may be a network error while
communicating with the client or a problem while storing the
uploaded content.@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<IFileItem> parseRequest(@Nonnull IRequestContext aCtx) throws FileUploadException
multipart/form-data stream.aCtx - The context for the request to be parsed.FileItem instances parsed from the request,
in the order that they were transmitted.FileUploadException - if there are problems reading/parsing the request or storing files.@Nullable protected byte[] getBoundary(@Nonnull String sContentType)
Content-type header.sContentType - The value of the content type header from which to extract the
boundary value.@Nullable protected String getFileName(@Nonnull IFileItemHeaders aHeaders)
Content-disposition header.aHeaders - The HTTP headers object.encapsulation.@Nullable protected String getFieldName(@Nonnull IFileItemHeaders aFileItemHeaders)
Content-disposition header.aFileItemHeaders - A Map containing the HTTP request headers.encapsulation.@Nonnull protected IFileItemHeaders getParsedHeaders(@Nonnull String sHeaderPart)
Parses the header-part and returns as key/value pairs.
If there are multiple headers of the same names, the name will map to a comma-separated list containing the values.
sHeaderPart - The header-part of the current
encapsulation.Map containing the parsed HTTP request headers.@Nonnull protected FileItemHeaders createFileItemHeaders()
IFileItemHeaders.Copyright © 2014–2019 Philip Helger. All rights reserved.