Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Primefaces 6.2 fileUpload thresholdSize setting on Liferay 7.0 GA7
So I got a Primefaces portlet with a p:fileUpload tag in it. Everything seems to work fine without having to modify my web.xml or pom.xml file to include fileUpload specific stuff. I was hoping the include the thresholdSize parameter in my web.xml in order not write files to disk that when they're less then 1mb. However I'm not finding the magic sauce yet to make that work. I first tried adding the following to my web.xml file:
None of these changes seem to help to stop the upload files from getting temporarily stored in the file system. Finally here's what my fileUpload tag looks like:
<context-param>
<param-name>primefaces.UPLOADER</param-name>
<param-value>commons</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>
org.primefaces.webapp.filter.FileUploadFilter
</filter-class>
<init-param>
<param-name>thresholdSize</param-name>
<param-value>1000000</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
Of course the servlet tag was already there but my files still get written to liferay's tomcat's temp folder. So I tried adding the following to my .xhtml view file<h:form id="taskForm" enctype="multipart/form-data" onkeypress="if (event.keyCode == 13) { return false; }">
</h:form>
This ensures the encoding type is multipart for the form enclosing the fileUpload. I didn't to need before as well.I also tried adding the following to my portlet pom.xml: <dependency>
<groupid>commons-fileupload</groupid>
<artifactid>commons-fileupload</artifactid>
<version>1.3.1</version>
<optional>true</optional>
</dependency>
<dependency>
<groupid>commons-io</groupid>
<artifactid>commons-io</artifactid>
<version>2.4</version>
<optional>true</optional>
</dependency>
None of these changes seem to help to stop the upload files from getting temporarily stored in the file system. Finally here's what my fileUpload tag looks like:
<p:fileupload id="extractionCSVUpload" update=":taskForm:tasksTable" rendered="#{tasksView.selectedTask.reviewType == 'csv'}" disabled="#{tasksView.selectedTask == null || tasksView.isCurrentAssignee() == false}" fileUploadListener="#{tasksView.handleFileUpload}" mode="advanced" skinSimple="true" auto="true" label="CSV" />
Any help would be greatly appreciated.
Hi Bill,
Apologies, but in-memory file upload isn't supported. :-(
Liferay Faces Bridge takes the responsibility of handling the file upload for all supported component suites. In the case of PrimeFaces, we decorate the p:fileUpload renderer and prevent PrimeFaces from trying to handle it.
For Portlet 2.0, Liferay Faces Bridge relies on Commons-Fileupload to get the job done. Although it has a "threshold" feature for in-memory file uploads, we specifically don't support it. For more info, see MultiPartFormDataProcessorCompatImpl.java lines 90-92.
When the Portlet 3.0 release is done, Liferay Faces Bridge will rely on the ClientDataRequest.getPart() feature of the Portlet 3.0 API, which further encapsulates/hides the file upload implementation from the JSF portlet application.
Best Regards,
Neil
Apologies, but in-memory file upload isn't supported. :-(
Liferay Faces Bridge takes the responsibility of handling the file upload for all supported component suites. In the case of PrimeFaces, we decorate the p:fileUpload renderer and prevent PrimeFaces from trying to handle it.
For Portlet 2.0, Liferay Faces Bridge relies on Commons-Fileupload to get the job done. Although it has a "threshold" feature for in-memory file uploads, we specifically don't support it. For more info, see MultiPartFormDataProcessorCompatImpl.java lines 90-92.
When the Portlet 3.0 release is done, Liferay Faces Bridge will rely on the ClientDataRequest.getPart() feature of the Portlet 3.0 API, which further encapsulates/hides the file upload implementation from the JSF portlet application.
Best Regards,
Neil
Thanks Neil. This definitely clarifies what I've been seeing. I can't I didn't know this before.
The Liferay upload related properties seem to have no effect either. Is that true?
Hi Bill,
There are three different options you can specify in either web.xml (affects all portlets) or portlet.xml (affects individual portlets):
1) com.liferay.faces.util.uploadedFileMaxSize
https://github.com/liferay/liferay-faces-util/blob/master/src/main/java/com/liferay/faces/util/config/WebConfigParam.java#L89
2) com.liferay.faces.bridge.uploadedFileMaxSize
3) javax.faces.UPLOADED_FILE_MAX_SIZE
https://github.com/liferay/liferay-faces-bridge-impl/blob/master/bridge-impl/src/main/java/com/liferay/faces/bridge/internal/PortletConfigParam.java#L117
#1 wins over #2 and #3. #2 and #3 are effectively synonyms.
Neil
There are three different options you can specify in either web.xml (affects all portlets) or portlet.xml (affects individual portlets):
1) com.liferay.faces.util.uploadedFileMaxSize
https://github.com/liferay/liferay-faces-util/blob/master/src/main/java/com/liferay/faces/util/config/WebConfigParam.java#L89
2) com.liferay.faces.bridge.uploadedFileMaxSize
3) javax.faces.UPLOADED_FILE_MAX_SIZE
https://github.com/liferay/liferay-faces-bridge-impl/blob/master/bridge-impl/src/main/java/com/liferay/faces/bridge/internal/PortletConfigParam.java#L117
#1 wins over #2 and #3. #2 and #3 are effectively synonyms.
Neil
Just as a side note it be useful if the following could be added into the bridge as well:
Set the threshold size to prevent extraneous serialization of uploaded data.Defaults:
Set the threshold size to prevent extraneous serialization of uploaded data.Defaults:
com.liferay.portal.upload.LiferayFileItem.threshold.size=262144
Set the temp directory for uploaded files.Examples: com.liferay.portal.upload.UploadServletRequestImpl.temp.dir=C:/Temp
Thanks again Neil.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™