net.jot.web.multipart
Class JOTMultiPartParser
java.lang.Object
net.jot.web.multipart.JOTMultiPartParser
public class JOTMultiPartParser
- extends java.lang.Object
This class is designed to parse a request coming from a multipart encoded form (ie: file upload form)
This does not support the full multipart spec, but support mixed form fields and files (multiple ok).
After calling request.parseMultiPartContent() you will get the following in the request:
The eventual regular form fields(text) will go automatically in the request so you can use them as ususal with request.getParameter()
If their are files, they will be stored in the request as well, so you can later use request.getFile("name"); and save/process the data.
Example of use:
request.parseMultiPartContent("/tmp", 50000000);
String someField=request.getParameter("htmlField1");
JOTMultiPartItem item=request.getFile("htmlFile1");
File f=new File("/tmp",item.getFileName());
FileOutputStream fos=new FileOutputStream(f);
item.copyDataTo(fos);
fos.flush();
fos.close();
- Author:
- thibautc
|
Method Summary |
static void |
parse(JOTFlowRequest request,
java.io.File tempFile,
long maxContentSize)
Parses the multipart form data, not called by default on regular requests, so you need to manually call request.parseMultiPartContent() . |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JOTMultiPartParser
public JOTMultiPartParser()
parse
public static void parse(JOTFlowRequest request,
java.io.File tempFile,
long maxContentSize)
throws java.lang.Exception
- Parses the multipart form data, not called by default on regular requests, so you need to manually call request.parseMultiPartContent() .
- Parameters:
request - tempFile - : a temporary file where the raw multipart data will be written.maxContentSize - : maximum size (total) to accept
- Throws:
java.lang.Exception