title: Upload multipart file using camel rest DSL
body: <p>I wish to upload a multipart file which includes a file and some json and output the file to a local folder using camel rest dsl. </p>
  
  <p>I am using a processor in the route to split the multipart request into the parts using HttpServletRequest.getPart() however I receive the following error:</p>
  
  <pre><code>java.lang.IllegalStateException: No multipart config for servlet
  </code></pre>
  
  <p>I have added a MultiPartFilter to the servlet and have tried both with and without a multipartResolver bean. When I'm debugging the processor I can see that the HttpServletRequest request object is actually a MultiPartFilter$Wrapper but the exception is still occurring.</p>
  
  <p>Upload form in html page:</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
      &lt;form action="http://localhost:8080/content/publish" method="post" enctype="multipart/form-data"&gt;
          &lt;p&gt;
              Json: &lt;input type="text" name="json"/&gt;
          &lt;/p&gt;
          &lt;p&gt;
              File: &lt;input type="file" name="uploadedFile" multiple="true" /&gt;
          &lt;/p&gt;
          &lt;input type="submit" value="Upload" /&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Route to process the request:</p>
  
  <pre><code>rest("/content").post("/publish").consumes("multipart/form-data").route().process(new MultipartProcessor()).to("file:src/main/resources/testUpload");
  </code></pre>
  
  <p>The request:</p>
  
  <pre><code>------WebKitFormBoundaryOAiLMJtrA2g4CB32
  Content-Disposition: form-data; name="json"
  
  { "json" : "test" }
  ------WebKitFormBoundaryOAiLMJtrA2g4CB32
  Content-Disposition: form-data; name="uploadedFile"; filename="test.txt"
  Content-Type: text/plain
  
  
  ------WebKitFormBoundaryOAiLMJtrA2g4CB32--
  </code></pre>
  
  <p>MultipartProcessor:</p>
  
  <pre><code>@Override
  public void process(Exchange exchange) throws Exception {
      HttpMessage message = exchange.getIn(HttpMessage.class);
      HttpServletRequest request = message.getRequest();
      Part file = request.getPart("uploadedFile");
      // then process to output file
  }
  </code></pre>
  
  <p>In web.xml:</p>
  
  <pre><code>  &lt;servlet&gt;
      &lt;display-name&gt;Camel Http Transport Servlet&lt;/display-name&gt;
      &lt;servlet-name&gt;CamelServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.apache.camel.component.servlet.CamelHttpTransportServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;CamelServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
    &lt;filter&gt;
          &lt;filter-name&gt;MultipartFilter&lt;/filter-name&gt;
          &lt;filter-class&gt;org.eclipse.jetty.servlets.MultiPartFilter&lt;/filter-class&gt;
     &lt;/filter&gt;  
  
     &lt;filter-mapping&gt;
          &lt;filter-name&gt;MultipartFilter&lt;/filter-name&gt;
          &lt;servlet-name&gt;CamelServlet&lt;/servlet-name&gt;  
     &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>Multipart resolver in camel-context.xml:</p>
  
  <pre><code>&lt;bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/&gt;
  </code></pre>