org.zkoss.zk.au.http
Class AuUploader

java.lang.Object
  extended by org.zkoss.zk.au.http.AuUploader
All Implemented Interfaces:
AuProcessor

public class AuUploader
extends java.lang.Object
implements AuProcessor

The utility used to process file upload.

Since:
3.0.2
Author:
tomyeh

Constructor Summary
AuUploader()
           
 
Method Summary
protected  java.lang.String handleError(java.lang.Throwable ex)
          Handles the exception that was thrown when uploading files, and returns the error message.
static boolean isMultipartContent(javax.servlet.http.HttpServletRequest request)
          Returns whether the request contains multipart content.
 void process(Session sess, javax.servlet.ServletContext ctx, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String pathInfo)
          Processes a file uploaded from the client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuUploader

public AuUploader()
Method Detail

process

public void process(Session sess,
                    javax.servlet.ServletContext ctx,
                    javax.servlet.http.HttpServletRequest request,
                    javax.servlet.http.HttpServletResponse response,
                    java.lang.String pathInfo)
             throws javax.servlet.ServletException,
                    java.io.IOException
Processes a file uploaded from the client.

Specified by:
process in interface AuProcessor
Parameters:
sess - the session, or null if the session is not available.
ctx - the servlet context (never null).
request - the request (never null).
response - the response (never null).
pathInfo - the path info. It includes the prefix when the Au processor is associated (see DHtmlUpdateServlet.addAuProcessor(org.zkoss.zk.ui.WebApp, java.lang.String, org.zkoss.zk.au.http.AuProcessor). For example, if an AU processor is assoicated with "/upload", then pi must start with "/upload". Note: it might end with other string depending on the URI you generated to the client.
Throws:
javax.servlet.ServletException
java.io.IOException

handleError

protected java.lang.String handleError(java.lang.Throwable ex)
Handles the exception that was thrown when uploading files, and returns the error message. When uploading file(s) causes an exception, this method will be called to generate the proper error message.

By default, it logs the error and then use Exceptions.getMessage(java.lang.Throwable) to retrieve the error message.

If you prefer not to log or to generate the custom error message, you can extend this class and override this method. Then, specify it in web.xml as follows.

<servlet>
  <servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class>
  <init-param>
    <param-name>processor0</param-name>
    <param-value>/upload=com.my.MyUploader</param-value>
  </init-param>
...

Parameters:
ex - the exception. Typical exceptions include org.apache.commons.fileupload .FileUploadBase.SizeLimitExceededException
Since:
3.0.4

isMultipartContent

public static final boolean isMultipartContent(javax.servlet.http.HttpServletRequest request)
Returns whether the request contains multipart content.



Copyright &copy; 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo