org.apache.click.extras.gae
Class MemoryFileUploadService

java.lang.Object
  extended by org.apache.click.service.CommonsFileUploadService
      extended by org.apache.click.extras.gae.MemoryFileUploadService
All Implemented Interfaces:
FileUploadService

public class MemoryFileUploadService
extends CommonsFileUploadService

Provides an Apache Commons In-Memory FileUploadService class.

This service creates an MemoryFileItemFactory for creating In-Memory FileItem instances which content is never written to disk.

This service is recommended to be used with Google App Engine (GAE) which doesn't allow Web Application access to disk.

To use this service in your GAE applications, add the following to your click.xml config:

 <file-upload-service classname="org.apache.click.extras.gae.MemoryFileUploadService">
     <!-- Set the total request maximum size to 10mb (10 x 1024 x 1024 = 10485760). -->
     <property name="sizeMax" value="10485760"/>

     <!-- Set the maximum individual file size to 2mb (2 x 1024 x 1024 = 2097152). -->
     <property name="fileSizeMax" value="2097152"/>
 </file-upload-service> 
To prevent users from uploading exceedingly large files you can configure MemoryFileUploadService through the properties CommonsFileUploadService.setSizeMax(long) and CommonsFileUploadService.setFileSizeMax(long), as demonstrated above.

Please note: Google App Engine further restricts the size of file uploads as well. Currently the limit is 10MB.


Field Summary
 
Fields inherited from class org.apache.click.service.CommonsFileUploadService
fileSizeMax, sizeMax
 
Fields inherited from interface org.apache.click.service.FileUploadService
UPLOAD_EXCEPTION
 
Constructor Summary
MemoryFileUploadService()
           
 
Method Summary
 FileItemFactory createFileItemFactory(HttpServletRequest request)
          Create and return a new MemoryFileItemFactory instance.
 void onInit(ServletContext servletContext)
           
 
Methods inherited from class org.apache.click.service.CommonsFileUploadService
getFileSizeMax, getSizeMax, onDestroy, parseRequest, setFileSizeMax, setSizeMax
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryFileUploadService

public MemoryFileUploadService()
Method Detail

onInit

public void onInit(ServletContext servletContext)
            throws Exception
Specified by:
onInit in interface FileUploadService
Overrides:
onInit in class CommonsFileUploadService
Parameters:
servletContext - the application servlet context
Throws:
Exception - if an error occurs initializing the FileUploadService
See Also:
FileUploadService.onInit(ServletContext)

createFileItemFactory

public FileItemFactory createFileItemFactory(HttpServletRequest request)
Create and return a new MemoryFileItemFactory instance.

Overrides:
createFileItemFactory in class CommonsFileUploadService
Parameters:
request - the servlet request
Returns:
a new MemoryFileItemFactory instance