UIX 2.2.16

oracle.cabo.servlet.io
Class DefaultFileUploadManager

java.lang.Object
  |
  +--oracle.cabo.servlet.io.FileUploadManager
        |
        +--oracle.cabo.servlet.io.BaseFileUploadManager
              |
              +--oracle.cabo.servlet.io.DefaultFileUploadManager

public class DefaultFileUploadManager
extends BaseFileUploadManager

DefaultFileUploadManager is initialized during UIX Servlet startup and destroyed on UIX Servlet shutdown. It is responsible for managing multipart form data upload requests, mapping them to a suitable PageEvent, for later use in an event handler.

DefaultFileUploadManager allows users to specify a maximum memory size limit for multipart file upload per one HTTP Post request. For the upload content that exceeds the limit, the content will be stored as a temporary file in a specified directory. Users can also specify a maximum size limit for files stored in the directory per request; if content exceeds that value, the request will be aborted.

Three servlet init parameters for oracle.cabo.servlet.UIXServlet are used to manage the memory useage:

      <init-param>
         <param-name>oracle.cabo.servlet.io.MaxMemory</param-name>
         <param-value>102400</param-value>
      </init-param>
      <init-param>
         <param-name>oracle.cabo.servlet.io.MaxDiskSpace</param-name>
         <param-value>1024000</param-value>
      </init-param>
      <init-param>
         <param-name>oracle.cabo.servlet.io.TempDirectory</param-name>
         <param-value>D:/temp/someDirectory</param-value>
      </init-param>
 
If they are not specified, the default value for oracle.cabo.servlet.io.MaxMemory is 102,400 bytes, the default value for oracle.cabo.servlet.io.MaxDiskSpace is 2,048,000 bytes, and the default value for oracle.cabo.servlet.io.TempDirectory is the server's temporary directory, as defined by Java's java.io.File API.

The parsed items are stored as UploadedFile objects in an UploadedFileMap, with HTML form file field names as keys. When the current Http request ends, the resources used by DefaultFileUploadManager will be released.

See Also:
UploadedFile, UploadedFileMap

Constructor Summary
DefaultFileUploadManager()
          Creates a DefaultFileUploadManager.
 
Method Summary
protected  java.lang.String doUploadFile(BajaContext context, Page page, MultipartFormItem item)
          Uploads a single file.
 long getMaxDiskSpace()
          Returns the maximum disk space that can be consumed while processing a single request.
 long getMaxMemory()
          Returns the maximum memory that can be consumed while processing a single request.
 java.lang.String getTempDirectory()
          Returns the directory that will be used to store temporary files.
 void init(javax.servlet.ServletConfig config)
          Initializes the DefaultFileUploadManager.
 void setMaxDiskSpace(long maxDiskSpace)
          Sets the maximum disk space that can be consumed while processing a single request.
 void setMaxMemory(long maxMemory)
          Sets the maximum memory that can be consumed while processing a single request.
 void setTempDirectory(java.lang.String tempDir)
          Sets the directory that will be used to store temporary files.
 
Methods inherited from class oracle.cabo.servlet.io.BaseFileUploadManager
decodeMultipartRequest, getMaximumAllowedBytes, setMaximumAllowedBytes
 
Methods inherited from class oracle.cabo.servlet.io.FileUploadManager
destroy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFileUploadManager

public DefaultFileUploadManager()
Creates a DefaultFileUploadManager.
Method Detail

init

public void init(javax.servlet.ServletConfig config)
Initializes the DefaultFileUploadManager.
Overrides:
init in class FileUploadManager
Parameters:
config - the servlet configuration

getMaxDiskSpace

public long getMaxDiskSpace()
Returns the maximum disk space that can be consumed while processing a single request.

setMaxDiskSpace

public void setMaxDiskSpace(long maxDiskSpace)
Sets the maximum disk space that can be consumed while processing a single request.

getMaxMemory

public long getMaxMemory()
Returns the maximum memory that can be consumed while processing a single request.

setMaxMemory

public void setMaxMemory(long maxMemory)
Sets the maximum memory that can be consumed while processing a single request.

getTempDirectory

public java.lang.String getTempDirectory()
Returns the directory that will be used to store temporary files. When set to null, temporary files will be stored using java.io.File.createTempFile().

setTempDirectory

public void setTempDirectory(java.lang.String tempDir)
Sets the directory that will be used to store temporary files. When set to null, temporary files will be stored using java.io.File.createTempFile().

doUploadFile

protected java.lang.String doUploadFile(BajaContext context,
                                        Page page,
                                        MultipartFormItem item)
                                 throws java.io.IOException
Uploads a single file.
Overrides:
doUploadFile in class BaseFileUploadManager
Following copied from class: oracle.cabo.servlet.io.BaseFileUploadManager
Parameters:
context - the BajaContext for this request
page - the page the file is being uploaded from; this page object has not yet been validated for login or any other handling
item - a MultipartFormItem that can be used to retrieve the file
Returns:
a value that will be inserted into the PageEvent as a substitute for the actual file contents.

UIX 2.2.16