Spring Framework
  1. Spring Framework
  2. SPR-3605

Declaring a multipartResolver bean limits file uploading capabilities

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      If a multipartResolver bean is declared in the context, say:

      <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
      <property name="maxUploadSize" value="25000000" />
      </bean>

      Every request that the dispatcher servlet handles is pre-processed by it, effectively removing the files from the request. This makes impossible to use in conjunction with other upload controllers (for example an AJAX monitor). A better approach would allow the user to configure the multipart resolver so it can be applied just to some requests and not all (based on the context path or a request parameter perhaps)

        Issue Links

          Activity

          Hide
          Narada Sage added a comment -

          Hi,

          I'd like to add a strong vote for this ticket. Our situation is that we have a lot of controllers already using Spring's file upload support. However now new controllers (featuring large multiple file upload) need to use Commons FileUpload (CFU) streaming API support. This is problematic because the multipartResolver is already declared and depended upon by already preexisting controllers so the bean cannot be removed. In the presence of multipartResolver as mentioned in this ticket already Spring intercepts the incoming request first and pre-processes it leaving CFU with zero uploaded files (http://commons.apache.org/fileupload/faq.html#empty-parse). In my case I have worked around this problem temporarily by creating an aspect which fools Spring into thinking that the request is in fact not multipart. The aspect only acts when a certain GET parameter is present in the incoming request such as '_multipartResolverDisable=1' and the request then passes through untouched to CFU for processing. I'd like to propose that the multipartResolver only apply to specific declared controllers (through configuration) or specific declared http requests (through http request parameters) as already suggested in this issue. Having it applicable application wide is a real inconvenience especially when implementing multiple file uploads which are not supported by the Spring form backing object bean thereby necessitating the direct use of CFU potentially in the presence of other controllers which are already using Spring support.

          Thanks.

          Show
          Narada Sage added a comment - Hi, I'd like to add a strong vote for this ticket. Our situation is that we have a lot of controllers already using Spring's file upload support. However now new controllers (featuring large multiple file upload) need to use Commons FileUpload (CFU) streaming API support. This is problematic because the multipartResolver is already declared and depended upon by already preexisting controllers so the bean cannot be removed. In the presence of multipartResolver as mentioned in this ticket already Spring intercepts the incoming request first and pre-processes it leaving CFU with zero uploaded files ( http://commons.apache.org/fileupload/faq.html#empty-parse ). In my case I have worked around this problem temporarily by creating an aspect which fools Spring into thinking that the request is in fact not multipart. The aspect only acts when a certain GET parameter is present in the incoming request such as '_multipartResolverDisable=1' and the request then passes through untouched to CFU for processing. I'd like to propose that the multipartResolver only apply to specific declared controllers (through configuration) or specific declared http requests (through http request parameters) as already suggested in this issue. Having it applicable application wide is a real inconvenience especially when implementing multiple file uploads which are not supported by the Spring form backing object bean thereby necessitating the direct use of CFU potentially in the presence of other controllers which are already using Spring support. Thanks.
          Hide
          Nikhil Sidhaye added a comment -

          Hi All,

          The request is very valid. I also want to use some ajax monitor for displaying progress for uploading file. I resolve this for myself by using progress listener given by Apache File Upload only. May be above link helps other people to just go ahead until Spring Source comes with some other elegant solution.

          1. http://forum.springsource.org/showthread.php?t=32367

          2. http://www.javaworld.com/javaforums/showflat.php?Cat=2&Number=49773&an=0&page=0

          ./Nikhil

          Show
          Nikhil Sidhaye added a comment - Hi All, The request is very valid. I also want to use some ajax monitor for displaying progress for uploading file. I resolve this for myself by using progress listener given by Apache File Upload only. May be above link helps other people to just go ahead until Spring Source comes with some other elegant solution. 1. http://forum.springsource.org/showthread.php?t=32367 2. http://www.javaworld.com/javaforums/showflat.php?Cat=2&Number=49773&an=0&page=0 ./Nikhil

            People

            • Assignee:
              Juergen Hoeller
              Reporter:
              Jose Noheda
              Last updater:
              Trevor Marshall
            • Votes:
              8 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                3 years, 49 weeks, 1 day ago