The default org.
implementation. This implementation creates
org. instances which keep
their
content either in memory, for smaller items, or in a temporary file on disk,
for larger items. The size threshold, above which content will be stored on
disk, is configurable, as is the directory in which temporary files will be
created.
If not otherwise configured, the default configuration values are as follows:
System.getProperty("java.io.tmpdir").Note
Files are created in the system default temp directory with
predictable names. This means that a local attacker with write access to that
directory can perform a TOUTOC attack to replace any uploaded file with a
file of the attackers choice. The implications of this will depend on how the
uploaded file is used but could be significant. When using this
implementation in an environment with local, untrusted users,
setRepository(File) MUST be used to configure a repository location
that is not publicly writable. In a Servlet container the location identified
by the ServletContext attribute jakarta.servlet.context.tempdir
may be used.
Temporary files, which are created for file items, will be deleted when the associated request is recycled.
| Modifier and Type | Field and Description |
|---|---|
| public static final int | DEFAULT_SIZE_THRESHOLD
The default threshold above which uploads will be stored on disk. |
| private String | defaultCharset
Default content charset to be used when no explicit charset parameter is provided by the sender. |
| private File | repository
The directory in which uploaded files will be stored, if stored on disk. |
| private int | sizeThreshold
The threshold above which uploads will be stored on disk. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | DiskFileItemFactory(final int
The threshold, in bytes, below which items will be
retained in memory and above which they will be
stored as a file. sizeThreshold, final File The data repository, which is the directory in
which files will be created, should the item size
exceed the threshold. repository)Constructs a preconfigured instance of this class. |
| Modifier and Type | Method and Description |
|---|---|
| public FileItem | Returns: The newly created file item.The name of the form field. fieldName, final String The content type of the form field. contentType, final boolean true if this is a plain form field;
false otherwise.The name of the uploaded file, if any, as supplied
by the browser or other client. fileName)Implements org. Create a new |
| public String | Returns: the default charsetReturns the default charset for use when no explicit charset parameter is provided by the sender. |
| public File | Returns: The directory in which temporary files will be located.Returns the directory used to temporarily store files that are larger than the configured size threshold. |
| public int | Returns: The size threshold, in bytes.Returns the size threshold beyond which files are written directly to disk. |
| public void | setDefaultCharset(final String
the default charset pCharset)Sets the default charset for use when no explicit charset parameter is provided by the sender. |
| public void | setRepository(final File
The directory in which temporary files will be located. repository)Sets the directory used to temporarily store files that are larger than the configured size threshold. |
| public void | setSizeThreshold(final int
The size threshold, in bytes. sizeThreshold)Sets the size threshold beyond which files are written directly to disk. |
| DEFAULT_SIZE_THRESHOLD | back to summary |
|---|---|
| public static final int DEFAULT_SIZE_THRESHOLD The default threshold above which uploads will be stored on disk. | |
| defaultCharset | back to summary |
|---|---|
| private String defaultCharset Default content charset to be used when no explicit charset parameter is provided by the sender. | |
| repository | back to summary |
|---|---|
| private File repository The directory in which uploaded files will be stored, if stored on disk. | |
| sizeThreshold | back to summary |
|---|---|
| private int sizeThreshold The threshold above which uploads will be stored on disk. | |
| DiskFileItemFactory | back to summary |
|---|---|
| public DiskFileItemFactory() Constructs an unconfigured instance of this class. The resulting factory may be configured by calling the appropriate setter methods. | |
| DiskFileItemFactory | back to summary |
|---|---|
| public DiskFileItemFactory(final int sizeThreshold, final File repository) Constructs a preconfigured instance of this class.
| |
| createItem | back to summary |
|---|---|
| public FileItem createItem(final String fieldName, final String contentType, final boolean isFormField, final String fileName) Implements org. Create a new
| |
| getDefaultCharset | back to summary |
|---|---|
| public String getDefaultCharset() Returns the default charset for use when no explicit charset parameter is provided by the sender.
| |
| getRepository | back to summary |
|---|---|
| public File getRepository() Returns the directory used to temporarily store files that are larger than the configured size threshold.
| |
| getSizeThreshold | back to summary |
|---|---|
| public int getSizeThreshold() Returns the size threshold beyond which files are written directly to disk. The default value is 10240 bytes.
| |
| setDefaultCharset | back to summary |
|---|---|
| public void setDefaultCharset(final String pCharset) Sets the default charset for use when no explicit charset parameter is provided by the sender.
| |
| setRepository | back to summary |
|---|---|
| public void setRepository(final File repository) Sets the directory used to temporarily store files that are larger than the configured size threshold.
| |
| setSizeThreshold | back to summary |
|---|---|
| public void setSizeThreshold(final int sizeThreshold) Sets the size threshold beyond which files are written directly to disk.
| |