question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FileUpload: Spring Framework issue with commons-fileupload

See original GitHub issue

Describe the defect Listener of fileUpload is not invoked in advanced mode with common mode uploader.

Reproducer In the source of CommonsFileUploadDecoder, it looks like be possible to handle advanced mode, but simply not working. With native uploader, same code runs without any problem. Environment:

  • PF Version: 8.0
  • JSF + version: _e.g. Mojarra 2.2.20
  • Tomcat 8.5
  • Affected browsers: e.g. Chrome, IE, Edge ALL

To Reproduce Steps to reproduce the behavior: 1.

<h:form>  
   <p:fileUpload listener="#{fileUploadView.handleFileUpload}" mode="advanced" dragDropSupport="false"
                  update="messages" sizeLimit="100000" fileLimit="3" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />
 
    <p:growl id="messages" showDetail="true" />     
</h:form>

Based on the source from the following link. https://www.primefaces.org/showcase/ui/file/upload/single.xhtml

  1. Set upload mode to common.
<context-param>
    <param-name>primefaces.UPLOADER</param-name>
    <param-value>commons</param-value><!-- Allowed values: auto, native and commons. -->
</context-param>
<filter>
    <filter-name>primeFacesFileUploadFilter</filter-name>
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
        <init-param>
	       <param-name>thresholdSize</param-name>
	       <param-value>10000000000</param-value>
	</init-param>
	<init-param>
	        <param-name>uploadDirectory</param-name>
	        <param-value>/tmp/upload/</param-value>
	</init-param>
</filter>
<filter-mapping>
    <filter-name>primeFacesFileUploadFilter</filter-name>
    <servlet-name>facesServlet</servlet-name>
</filter-mapping>
  1. Listener not invoked.

Expected behavior It should work in common file upload mode as same as in native file upload mode.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:51 (35 by maintainers)

github_iconTop GitHub Comments

1reaction
mellowarecommented, Dec 11, 2020

@clockwiser I know this is for Spring Boot but this sounds an awful lot like your issue: https://stackoverflow.com/questions/51149162/spring-boot-streaming-apache-fileupload-stream-ended-unexpectedly

As I said some other Filter in your chain is somehow disturbing this process and corrupting or closing the stream.

1reaction
tandraschkocommented, Dec 7, 2020

@melloware better we avoid that. There can be a different form on the client or even no parent form on the server side. (because appendTo e.g.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem while uploading file in Spring with apache-commons ...
I'm trying to upload an image in a web application built on Spring MVC using local tomcat container, but the code continue to...
Read more >
Spring MVC File Upload Example Tutorial - DigitalOcean
Spring MVC framework provides support for uploading files by integrating Apache Commons FileUpload API. The process to upload files is very ...
Read more >
Upload files in Spring Boot application using Commons ...
In our previous post, we saw how to upload a file using the Spring framework's default implementation for MultipartFile interface.
Read more >
16.8 Spring's multipart (fileupload) support
The design for the multipart support is done with pluggable MultipartResolver objects, defined in the org.springframework.web.multipart package. Out of the box, ...
Read more >
Spring and Apache FileUpload - Baeldung
The Apache Commons File Upload Library helps us upload large files over the HTTP protocol using the multipart/form-data content type.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found