You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Am...@sungard.com on 2011/03/09 12:19:51 UTC

[fileupload]

I want to upload multiple files at a time using commons file upload jar.

 

How can I do it?

 

Thanks

Amit


RE: [fileupload] Issue in reading file from webserver to appserver

Posted by "Anbazhagan, Karunainathan" <Ka...@axa-equitable.com>.
Hi, 

 I am having issue with the file upload functionality. Please review
below details.
Any help would be appreciated.
 
Problem statement: 
 
 Not able to upload document to one of our website which uses common
file upload functionality. 
Webserver is not getting the file when the user is uploading the file to
website.
 
 
The site was running in,
 
Weblogic - 10.1
Apache    - 2.0.52 (Linux 2.6.9-67)
Common File upload - 1.1
 
 
Error message on the apache webserver logs:
 
[Fri Mar 04 14:11:01 2011] [error] [client 24.38.26.132] ap_proxy:
trying POST /xxxxxxxx/xxxxxxxxxxAction.do at backend host
'10.x.x.x/<port no>; got exception 'READ_ERROR_FROM_FILE [os error=0,
line 145 of ap_proxy.cpp]: Cannot read 0 bytes of postData from tmp file
'/tmp/_wl_proxy/_post_8835_0'', referer: 
 
Error message on the weblogic logs:
 
ERROR - 2010-12-13 16:29:46,625 [[ACTIVE] ExecuteThread: '2' for queue:
'weblogic.kernel.Default (self-tuning)']
upload.CommonsMultipartRequestHandler (handleRequest:241) - Failed to
parse multipart request
org.apache.commons.fileupload.FileUploadException: Processing of
multipart/form-data request failed. EOF after reading only: '0' of:
'26170' promised bytes, out of which at least: '0' were already buffered
        at
org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase
.java:429)
        at
org.apache.struts.upload.CommonsMultipartRequestHandler.handleRequest(Co
mmonsMultipartRequestHandler.java:233)
        at
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1209)
        at
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcess
or.java:821)
        at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:
254)
        at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
        at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)




Thanks,
Karunai

**********************************************************************

Confidentiality Note: This message and any attachments 
may contain legally privileged and/or confidential information. 
Any unauthorized disclosure, use or dissemination of this e-mail 
message or its contents, either in whole or in part, is prohibited. 
If you are not the intended recipient of this e-mail message, 
kindly notify the sender and then destroy it.

**********************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


RE: [fileupload]

Posted by Am...@sungard.com.
Sure chris.

Libraries I have used:

1. commons-io-2.0.1.jar
2. commons-fileupload-1.2.2.jar

Following is the servlet code:

// Create a factory for disk-based file items
			DiskFileItemFactory factory = new
DiskFileItemFactory();

			// Set factory constraints
			factory.setSizeThreshold(10000000);
			factory.setRepository(new File("C:\\uploads"));

			// Create a new file upload handler
			ServletFileUpload upload = new
ServletFileUpload(factory);

			// Set overall request size constraint
			upload.setSizeMax(10000000);

			// Parse the request
			List /* FileItem */ items =
upload.parseRequest(request);
			
			System.out.println("items no: " + items.size());
			
			// Process the uploaded items
			Iterator iter = items.iterator();
			
			boolean writeToFile = true;
			
			while (iter.hasNext()) 
			{
			    FileItem item = (FileItem) iter.next();
			    String fileName = item.getName();

			    System.out.println(fileName);
			    
			 // Process a file upload
			    if (writeToFile) 
			    {			    	
			        File uploadedFile = new
File("C:\\uploads\\" + FilenameUtils.getName(fileName));
			        item.write(uploadedFile);
			        
			    } else 
			    {
			        InputStream uploadedStream =
item.getInputStream();			        
			        uploadedStream.close();
			    }
			}

That's all

Amit

-----Original Message-----
From: christopher.alexander@novartis.com
[mailto:christopher.alexander@novartis.com] 
Sent: Thursday, March 10, 2011 7:19 PM
To: Commons Users List
Subject: RE: [fileupload]

Hi Amit,

Would you mind posting the code and list of libraries that is 
accomplishing the single file upload. If I can replicate this, maybe I
can 
assist in establishing multiple file upload. :)

Chris




<Am...@sungard.com> 
03/10/2011 01:28 AM
Please respond to
"Commons Users List" <us...@commons.apache.org>


To
<us...@commons.apache.org>
cc

Subject
RE: [fileupload]






Yes, I am able to upload single file at a time. But want to upload
multiple files at one go.

Amit

-----Original Message-----
From: christopher.alexander@novartis.com
[mailto:christopher.alexander@novartis.com] 
Sent: Thursday, March 10, 2011 2:37 AM
To: Commons Users List
Subject: Re: [fileupload]

Hi Amit,

To be truthful, I never got the damn thing working. Has anyone out there

actually been able to successfully get commons fileupload working?

Chris




<Am...@sungard.com> 
03/09/2011 06:22 AM
Please respond to
"Commons Users List" <us...@commons.apache.org>


To
<us...@commons.apache.org>
cc

Subject
[fileupload]






I want to upload multiple files at a time using commons file upload jar.

 

How can I do it?

 

Thanks

Amit




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


RE: [fileupload]

Posted by ch...@novartis.com.
Hi Amit,

Would you mind posting the code and list of libraries that is 
accomplishing the single file upload. If I can replicate this, maybe I can 
assist in establishing multiple file upload. :)

Chris




<Am...@sungard.com> 
03/10/2011 01:28 AM
Please respond to
"Commons Users List" <us...@commons.apache.org>


To
<us...@commons.apache.org>
cc

Subject
RE: [fileupload]






Yes, I am able to upload single file at a time. But want to upload
multiple files at one go.

Amit

-----Original Message-----
From: christopher.alexander@novartis.com
[mailto:christopher.alexander@novartis.com] 
Sent: Thursday, March 10, 2011 2:37 AM
To: Commons Users List
Subject: Re: [fileupload]

Hi Amit,

To be truthful, I never got the damn thing working. Has anyone out there

actually been able to successfully get commons fileupload working?

Chris




<Am...@sungard.com> 
03/09/2011 06:22 AM
Please respond to
"Commons Users List" <us...@commons.apache.org>


To
<us...@commons.apache.org>
cc

Subject
[fileupload]






I want to upload multiple files at a time using commons file upload jar.

 

How can I do it?

 

Thanks

Amit




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org



RE: [fileupload]

Posted by Am...@sungard.com.
Yes, I am able to upload single file at a time. But want to upload
multiple files at one go.

Amit

-----Original Message-----
From: christopher.alexander@novartis.com
[mailto:christopher.alexander@novartis.com] 
Sent: Thursday, March 10, 2011 2:37 AM
To: Commons Users List
Subject: Re: [fileupload]

Hi Amit,

To be truthful, I never got the damn thing working. Has anyone out there

actually been able to successfully get commons fileupload working?

Chris




<Am...@sungard.com> 
03/09/2011 06:22 AM
Please respond to
"Commons Users List" <us...@commons.apache.org>


To
<us...@commons.apache.org>
cc

Subject
[fileupload]






I want to upload multiple files at a time using commons file upload jar.

 

How can I do it?

 

Thanks

Amit




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [fileupload]

Posted by ch...@novartis.com.
Hi Amit,

To be truthful, I never got the damn thing working. Has anyone out there 
actually been able to successfully get commons fileupload working?

Chris




<Am...@sungard.com> 
03/09/2011 06:22 AM
Please respond to
"Commons Users List" <us...@commons.apache.org>


To
<us...@commons.apache.org>
cc

Subject
[fileupload]






I want to upload multiple files at a time using commons file upload jar.

 

How can I do it?

 

Thanks

Amit