to.etc.domui.util.upload
Class UploadParser

java.lang.Object
  extended by to.etc.domui.util.upload.UploadParser

public class UploadParser
extends java.lang.Object

This is a file upload parser which parses input type=file requests as posted from forms. It expects an input stream encoded as described in RFC 1867. The input stream is split into it's constituent parts and returned as a parameter map.

This code replaces the apache fileupload code because that code does not properly return the fact that *no* file was uploaded (i.e. the input was empty), and because that implementation does not return an actual File without casting.

To use this, first ask if a HttpRequest is a valid upload request using the "isMultipartContent()" call. Then ask an instance of this class to parse the request. This returns a Map of items present in the request.

Created on Nov 21, 2005

Author:
Frits Jalvingh

Constructor Summary
UploadParser()
           
 
Method Summary
 int getSizeMax()
           
static boolean isMultipartContent(javax.servlet.http.HttpServletRequest req)
          Returns T if the request is encoded as multipart (i.e.
 java.util.List<UploadItem> parseRequest(javax.servlet.http.HttpServletRequest ctx, java.lang.String hdrencoding)
           
 java.util.List<UploadItem> parseRequest(java.io.InputStream is, java.lang.String hdrencoding, java.lang.String contentType, int requestSize)
           
 void setSizeMax(int sizeMax)
           
static javax.servlet.http.HttpServletRequest wrapIfNeeded(javax.servlet.http.HttpServletRequest req)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UploadParser

public UploadParser()
Method Detail

getSizeMax

public final int getSizeMax()

setSizeMax

public final void setSizeMax(int sizeMax)

isMultipartContent

public static final boolean isMultipartContent(javax.servlet.http.HttpServletRequest req)
Returns T if the request is encoded as multipart (i.e. file upload).

Parameters:
req -
Returns:

wrapIfNeeded

public static final javax.servlet.http.HttpServletRequest wrapIfNeeded(javax.servlet.http.HttpServletRequest req)

parseRequest

public java.util.List<UploadItem> parseRequest(javax.servlet.http.HttpServletRequest ctx,
                                               java.lang.String hdrencoding)
                                        throws FileUploadException,
                                               java.io.IOException
Throws:
FileUploadException
java.io.IOException

parseRequest

public java.util.List<UploadItem> parseRequest(java.io.InputStream is,
                                               java.lang.String hdrencoding,
                                               java.lang.String contentType,
                                               int requestSize)
                                        throws FileUploadException,
                                               java.io.IOException
Throws:
FileUploadException
java.io.IOException