Where do I get the Request-Object
Dear Friends,
I want to upload a file via HTTP multipart-formdata request (POST).
For that reason I use the FileUpload-API:
http://jakarta.apache.org/commons/fileupload/using.html
Everything is described perfectly and I am very happy that there is such a project!
But they didn't write how I could create a new Request-Object.
How do I do that?
Are there are different types of Request-Objects?
Here is my test-code so far:
publicclass FileUploader12{
List items =new ArrayList();
/** Creates a new instance of FileUploader12 */
public FileUploader12(){
// Create a factory for disk-based file items
FileItemFactory factory =new DiskFileItemFactory();
// Create a new file upload handler
ServletFileUpload upload =new ServletFileUpload(factory);
// Parse the request
Request request =new Request();
/*FileItem */ items = upload.parseRequest(request);
//Create a progress listener
ProgressListener progressListener =new ProgressListener(){
privatelong megaBytes = -1;
publicvoid update(long pBytesRead,long pContentLength,int pItems){
long mBytes = pBytesRead / 1000000;
if (megaBytes == mBytes){
return;
}
megaBytes = mBytes;
System.out.println("We are currently reading item " + pItems);
if (pContentLength == -1){
System.out.println("So far, " + pBytesRead +" bytes have been read.");
}else{
System.out.println("So far, " + pBytesRead +" of " + pContentLength
+" bytes have been read.");
}
}
};
}
}
Thank you very much!
With best Regards
MfG
Inno

