Upload files larger than 20MB

Hi all,

I am using FileItem CAF component to upload files via portal page. It is allowing to upload files only upto 20MB :frowning: .

Is there any way to upload files of size >20MB via portal?

MWS has a global max upload size that is managed in the Content Service Admin portlet. By default, this is set to 20MB. Feel free to change this as you need.

If you want to have more fine grained control on a portlet application by portlet application basis, you can add the following JSF validator to your portlet app. However, no multipart Http POST will get to your code if it is larger than the global max upload file size.

This code sample limits the uploaded file to be 4MB


/** 
 * Validator to check file size 
 */ 
public void customFile_validator(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.Object value) { 
	if (value instanceof FileItem) { 
		FileItem fileItem = (FileItem)value; 
		
		long maxSize = 4 * 1024000; //4 MB 
		if (maxSize < fileItem.getSize()) { 
					//file is too big, so throw a validator exception 
					throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, 
											"File must be smaller than 4 MB", 
											"File must be smaller than 4 MB")); 
		} 
	} 
} 

hi Mimel,

Thank you for the reply.
I set MAX FILE SIZE to 50 MB in Content Service portlet and tried to upload 21 MB size file.

It gave following exception:

org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (21620270) exceeds the configured maximum (10485760)

In web.xml there is one init-param MAX_UPLOAD_DISK_SIZE for filter ā€˜Multipart Filterā€™. By default it was set to 10MB. I changed it to 50MB.
But still the same error is coming.

Not able to identify where the max upload size was set to 10485760 bytes.

Could you please let me know if you have any idea?

That is 10MB. 1024102410=10485760

Iā€™ll try to repro this locally, but iā€™d like you to double check whether you redeployed and/or restarted MWS after making these changes.

Thanks,
ā€“mark

hi Mark,

Restarted server deployed the code and checked again, giving the same exception
org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (21620270) exceeds the configured maximum (10485760)

I suspect that, in some other configuration file MAX FILE SIZE is set to 10485760 bytes (10MB).

Thanks,
Raja sekhar

The default size for the Portletā€™s Multipart Filter is 10MB. I wasnā€™t clear at all about where to set the Init Param, so iā€™ve attached a sample that you can try out and see where the Init Param should be set (look in the web.xml).

Below is a snippet of the web.xml


	<filter>
		<description>
		Handles multipart form POSTs (file uploads); required by FileInput control.</description>
		<filter>Multipart Filter</filter>
		<filter>com.webmethods.caf.faces.servlet.MultipartFilter</filter>
		<init>
			<param>MAX_UPLOAD_DISK_SIZE</param>
			<param>30 MB</param>
		</init>
	</filter>

LargeFileUploadApp.zip (9.36 KB)

Hello Mark.

Iā€™ve tried to open your project but I was not able to.

Iā€™m using 7.1.2 Designer.

I have the same problem as stated before, and after setting those values in the Web.xml we still get the same error ā€œorg.apache.commons.fileupload.FileUploadBase$SizeLimitExceededExceptionā€

Can you help?

Hi Mark.

Iā€™ve managed to import your project to my Designer, sorry for the last Post.

In the meantimeā€¦ Iā€™ve looked at your code and your ā€œUpload Fileā€ action button does nothingā€¦ and itā€™s an async button.

Are you able to upload a file with an async button?

Edited

In 7.x, youā€™ll need to use a SYNC command Button, but in 8.x you can use an Async command button.

Let me know if you need anything additional on this topic.
Regards,
ā€“mark

Edited
Ok, i think the issue is that iā€™m using 8.x for this sample. Iā€™ll start investigating for 7.x.

Regards,
ā€“mark