org.apache.tomcat.util.http.fileupload

Class DiskFileUpload

public class DiskFileUpload extends FileUploadBase

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. Use DiskFileUpload to acquire a list of FileItems associated with a given HTML widget.

Individual parts will be stored in temporary disk storage or in memory, depending on their size, and will be available as FileItems.

Version: $Id: DiskFileUpload.java 467222 2006-10-24 03:17:11Z markt $

Author: Rafal Krzewski Daniel Rall Jason van Zyl John McNally Martin Cooper Sean C. Sullivan

Constructor Summary
DiskFileUpload()
Constructs an instance of this class which uses the default factory to create FileItem instances.
DiskFileUpload(DefaultFileItemFactory fileItemFactory)
Constructs an instance of this class which uses the supplied factory to create FileItem instances.
Method Summary
FileItemFactorygetFileItemFactory()
Returns the factory class used when creating file items.
StringgetRepositoryPath()
Returns the location used to temporarily store files that are larger than the configured size threshold.
intgetSizeThreshold()
Returns the size threshold beyond which files are written directly to disk.
ListparseRequest(HttpServletRequest req, int sizeThreshold, long sizeMax, String path)
Processes an RFC 1867 compliant multipart/form-data stream.
voidsetFileItemFactory(FileItemFactory factory)
Sets the factory class to use when creating file items.
voidsetRepositoryPath(String repositoryPath)
Sets the location used to temporarily store files that are larger than the configured size threshold.
voidsetSizeThreshold(int sizeThreshold)
Sets the size threshold beyond which files are written directly to disk.

Constructor Detail

DiskFileUpload

public DiskFileUpload()
Constructs an instance of this class which uses the default factory to create FileItem instances.

See Also: DiskFileUpload

DiskFileUpload

public DiskFileUpload(DefaultFileItemFactory fileItemFactory)
Constructs an instance of this class which uses the supplied factory to create FileItem instances.

See Also: DiskFileUpload

Method Detail

getFileItemFactory

public FileItemFactory getFileItemFactory()
Returns the factory class used when creating file items.

Returns: The factory class for new file items.

getRepositoryPath

public String getRepositoryPath()
Returns the location used to temporarily store files that are larger than the configured size threshold.

Returns: The path to the temporary file location.

See Also: setRepositoryPath

getSizeThreshold

public int getSizeThreshold()
Returns the size threshold beyond which files are written directly to disk.

Returns: The size threshold, in bytes.

See Also: DiskFileUpload

parseRequest

public List parseRequest(HttpServletRequest req, int sizeThreshold, long sizeMax, String path)
Processes an RFC 1867 compliant multipart/form-data stream. If files are stored on disk, the path is given by getRepository().

Parameters: req The servlet request to be parsed. Must be non-null. sizeThreshold The max size in bytes to be stored in memory. sizeMax The maximum allowed upload size, in bytes. path The location where the files should be stored.

Returns: A list of FileItem instances parsed from the request, in the order that they were transmitted.

Throws: FileUploadException if there are problems reading/parsing the request or storing files.

setFileItemFactory

public void setFileItemFactory(FileItemFactory factory)
Sets the factory class to use when creating file items. The factory must be an instance of DefaultFileItemFactory or a subclass thereof, or else a ClassCastException will be thrown.

Parameters: factory The factory class for new file items.

setRepositoryPath

public void setRepositoryPath(String repositoryPath)
Sets the location used to temporarily store files that are larger than the configured size threshold.

Parameters: repositoryPath The path to the temporary file location.

See Also: getRepositoryPath

setSizeThreshold

public void setSizeThreshold(int sizeThreshold)
Sets the size threshold beyond which files are written directly to disk.

Parameters: sizeThreshold The size threshold, in bytes.

See Also: getSizeThreshold

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.