title: Camel send multipart/form-data request
body: <p>I have an app, that sends a multipart/form-data &amp; an app that recieves multipart/form-data request.</p>
  
  <p>Processing in reciever: </p>
  
  <pre><code>    InputStreamCache postBody = exchange.getIn().getBody(InputStreamCache.class);
      MultipartUploadContext mux = new MultipartUploadContext(postBody, exchange.getIn().getHeader("Content-Type",String.class));
      Map&lt;String,Object&gt; params = mux.parseRequest();
  </code></pre>
  
  <p>Parsing a request, send from Postman/Swagger works fine.
  I have troubles integrating my camel-sender with my camel reciever.</p>
  
  <p>Here is the sender route:</p>
  
  <pre><code>from("direct:uploadFileToRest").routeId("uploadFileToRest").
      process("uploadFileRequestProcessor").
      setHeader(Exchange.HTTP_METHOD, simple("POST")).
      setHeader(Exchange.CONTENT_TYPE, constant("multipart/form-data")).
      to("myrecieverapp/full_upload").
      id("fileUploadRestSending").
      log(LoggingLevel.DEBUG, "RESPONSE BODY ${body}").
  end();
  </code></pre>
  
  <p>The sender processor:</p>
  
  <pre><code>MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder
                  .create()
                  .addTextBody("name", "SomeName")
                  .addBinaryBody("content", array_with_byte_content_here);
  exchange.getOut().setBody(multipartEntityBuilder.build());
  </code></pre>
  
  <p>The following error occures:</p>
  
  <pre><code> No body available of type: java.io.InputStream but has value: org.apache.http.entity.mime.MultipartFormEntity@35315261 of type: org.apache.http.entity.mime.MultipartFormEntity on: Message[ID-VRN26-1529401997491-0-3]. Caused by: No type converter available to convert from type: org.apache.http.entity.mime.MultipartFormEntity to the required type: java.io.InputStream with value org.apache.http.entity.mime.MultipartFormEntity@35315261.
  </code></pre>
  
  <p>After looking up for the same issue, I found up a recommendation to change out body to:</p>
  
  <pre><code> exchange.getOut().setBody(multipartEntityBuilder.build().getContent());
  </code></pre>
  
  <p>However,it causes issues on reciever side:</p>
  
  <pre><code>the request was rejected because no multipart boundary was found\r\n\tat org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.&lt;init&gt;(FileUploadBase.java:990)\r\n\tat org.apache.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:310)\r\n\tat org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:334)\r\n\tat ru.cinimex.abb.fileuploader.util.MultipartUploadContext.parseRequest(MultipartUploadContext.java:29)\r\n\tat ru.cinimex.abb.fileuploader.camel.processors.ValidateFullUploadRequestProcessor.process(ValidateFullUploadRequestProcessor.java:33)\r\n\tat org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSyncProcessor.java:63)\r\n\tat org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)\r\n\tat 
  </code></pre>
  
  <p>I've read theese posts:</p>
  
  <p><a href="http://hilton.org.uk/blog/camel-multipart-form-data" rel="nofollow noreferrer">http://hilton.org.uk/blog/camel-multipart-form-data</a></p>
  
  <p><a href="https://stackoverflow.com/questions/28815792/apache-camel-multipart-route">Apache Camel multipart route</a></p>
  
  <p>but couldn't find a solution</p>
  
  <p>Camel version: org.apache.camel:camel-cxf:2.21.0.000033-fuse-000001-redhat-1</p>