|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.fileupload.disk.DiskFileItemFactory
public class DiskFileItemFactory
The default FileItemFactory
implementation. This implementation creates
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:
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 File
is garbage collected.)
Cleaning up those files is done by an instance of
FileCleaningTracker
, and an associated thread. In a complex
environment, for example in a web application, you should consider
terminating this thread, for example, when your web application
ends. See the section on "Resource cleanup"
in the users guide of commons-fileupload.
Field Summary | |
---|---|
static int |
DEFAULT_SIZE_THRESHOLD
The default threshold above which uploads will be stored on disk. |
Constructor Summary | |
---|---|
DiskFileItemFactory()
Constructs an unconfigured instance of this class. |
|
DiskFileItemFactory(int sizeThreshold,
java.io.File repository)
Constructs a preconfigured instance of this class. |
Method Summary | |
---|---|
FileItem |
createItem(java.lang.String fieldName,
java.lang.String contentType,
boolean isFormField,
java.lang.String fileName)
Create a new DiskFileItem
instance from the supplied parameters and the local factory
configuration. |
org.apache.commons.io.FileCleaningTracker |
getFileCleaningTracker()
Returns the tracker, which is responsible for deleting temporary files. |
java.io.File |
getRepository()
Returns the directory used to temporarily store files that are larger than the configured size threshold. |
int |
getSizeThreshold()
Returns the size threshold beyond which files are written directly to disk. |
void |
setFileCleaningTracker(org.apache.commons.io.FileCleaningTracker pTracker)
Returns the tracker, which is responsible for deleting temporary files. |
void |
setRepository(java.io.File repository)
Sets the directory used to temporarily store files that are larger than the configured size threshold. |
void |
setSizeThreshold(int sizeThreshold)
Sets the size threshold beyond which files are written directly to disk. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_SIZE_THRESHOLD
Constructor Detail |
---|
public DiskFileItemFactory()
public DiskFileItemFactory(int sizeThreshold, java.io.File repository)
sizeThreshold
- The threshold, in bytes, below which items will be
retained in memory and above which they will be
stored as a file.repository
- The data repository, which is the directory in
which files will be created, should the item size
exceed the threshold.Method Detail |
---|
public java.io.File getRepository()
setRepository(java.io.File)
public void setRepository(java.io.File repository)
repository
- The directory in which temporary files will be located.getRepository()
public int getSizeThreshold()
setSizeThreshold(int)
public void setSizeThreshold(int sizeThreshold)
sizeThreshold
- The size threshold, in bytes.getSizeThreshold()
public FileItem createItem(java.lang.String fieldName, java.lang.String contentType, boolean isFormField, java.lang.String fileName)
DiskFileItem
instance from the supplied parameters and the local factory
configuration.
createItem
in interface FileItemFactory
fieldName
- The name of the form field.contentType
- The content type of the form field.isFormField
- true
if this is a plain form field;
false
otherwise.fileName
- The name of the uploaded file, if any, as supplied
by the browser or other client.
public org.apache.commons.io.FileCleaningTracker getFileCleaningTracker()
FileCleaningTracker
, defaults to
FileCleaner.getInstance()
. Null,
if temporary files aren't tracked.public void setFileCleaningTracker(org.apache.commons.io.FileCleaningTracker pTracker)
pTracker
- An instance of FileCleaningTracker
,
which will from now on track the created files. May be null
to disable tracking.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |