| java.lang.Object org.apache.commons.fileupload.disk.DiskFileItemFactory
All known Subclasses: org.apache.commons.fileupload.DefaultFileItemFactory,
DiskFileItemFactory | public class DiskFileItemFactory implements FileItemFactory(Code) | | The default
org.apache.commons.fileupload.FileItemFactory implementation. This implementation creates
org.apache.commons.fileupload.FileItem 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:
- Size threshold is 10KB.
- Repository is the system default temp directory, as returned by
System.getProperty("java.io.tmpdir") .
When using the DiskFileItemFactory , then you should
consider the following: Temporary files are automatically deleted as
soon as they are no longer needed. (More precisely, when the
corresponding instance of
java.io.File is garbage collected.)
This is done by the so-called reaper thread, which is started
automatically when the class
org.apache.commons.io.FileCleaner is loaded. It might make sense to terminate that thread, for example,
if your web application ends. See the section on "Resource cleanup"
in the users guide of commons-fileupload.
author: Martin Cooper since: FileUpload 1.1 version: $Id: DiskFileItemFactory.java 502350 2007-02-01 20:42:48Z jochen $ |
Field Summary | |
final public static int | DEFAULT_SIZE_THRESHOLD The default threshold above which uploads will be stored on disk. |
Constructor Summary | |
public | DiskFileItemFactory() Constructs an unconfigured instance of this class. | public | DiskFileItemFactory(int sizeThreshold, File repository) Constructs a preconfigured instance of this class. |
Method Summary | |
public FileItem | createItem(String fieldName, String contentType, boolean isFormField, String fileName) Create a new
org.apache.commons.fileupload.disk.DiskFileItem instance from the supplied parameters and the local factory
configuration.
Parameters: fieldName - The name of the form field. Parameters: contentType - The content type of the form field. Parameters: isFormField - true if this is a plain form field;false otherwise. Parameters: fileName - The name of the uploaded file, if any, as suppliedby the browser or other client. | public File | getRepository() Returns the directory used to temporarily store files that are larger
than the configured size threshold. | public int | getSizeThreshold() Returns the size threshold beyond which files are written directly to
disk. | public void | setRepository(File repository) Sets the directory used to temporarily store files that are larger
than the configured size threshold. | public void | setSizeThreshold(int sizeThreshold) Sets the size threshold beyond which files are written directly to disk. |
DEFAULT_SIZE_THRESHOLD | final public static int DEFAULT_SIZE_THRESHOLD(Code) | | The default threshold above which uploads will be stored on disk.
|
DiskFileItemFactory | public DiskFileItemFactory()(Code) | | Constructs an unconfigured instance of this class. The resulting factory
may be configured by calling the appropriate setter methods.
|
DiskFileItemFactory | public DiskFileItemFactory(int sizeThreshold, File repository)(Code) | | Constructs a preconfigured instance of this class.
Parameters: sizeThreshold - The threshold, in bytes, below which items will beretained in memory and above which they will bestored as a file. Parameters: repository - The data repository, which is the directory inwhich files will be created, should the item sizeexceed the threshold. |
createItem | public FileItem createItem(String fieldName, String contentType, boolean isFormField, String fileName)(Code) | | Create a new
org.apache.commons.fileupload.disk.DiskFileItem instance from the supplied parameters and the local factory
configuration.
Parameters: fieldName - The name of the form field. Parameters: contentType - The content type of the form field. Parameters: isFormField - true if this is a plain form field;false otherwise. Parameters: fileName - The name of the uploaded file, if any, as suppliedby the browser or other client. The newly created file item. |
getSizeThreshold | public int getSizeThreshold()(Code) | | Returns the size threshold beyond which files are written directly to
disk. The default value is 10240 bytes.
The size threshold, in bytes. See Also: DiskFileItemFactory.setSizeThreshold(int) |
setRepository | public void setRepository(File repository)(Code) | | Sets the directory used to temporarily store files that are larger
than the configured size threshold.
Parameters: repository - The directory in which temporary files will be located. See Also: DiskFileItemFactory.getRepository() |
setSizeThreshold | public void setSizeThreshold(int sizeThreshold)(Code) | | Sets the size threshold beyond which files are written directly to disk.
Parameters: sizeThreshold - The size threshold, in bytes. See Also: DiskFileItemFactory.getSizeThreshold() |
|
|