I am working with a piece of web software that uploads files to a camel-jetty server. The uploads happen through BlueImp jQuery FileUpload (https://github.com/blueimp/jQuery-File-Upload) through the browser. The company I work for recently upgraded from Camel 2.3 to Camel 2.17 in our server-side Java project. We never had a problem before, but since we upgraded to the newer version the file uploads no longer work. Digging into it I have discovered a few strange things:
- exchange.getIn().getAttachments().size() == 0 (always)
- A NullPointerException is ALWAYS thrown in MultiPartFilter inside camel-jetty because it attempts to ALWAYS get the content-type of EVERY form-data part... even though every browser/agent I have tested by default will not set the content-type on every part.
I fixed the NullPointerException in jetty MultiPartFilter by following advice from another post that uses FormData and Blob directly in javascript to force a content-type on every form-data part (Composing multipart/form-data with a different Content-Type on each parts with Javascript (or Angular)). However, the exchange.getIn().getBody() is now always null, and exchange.getIn().getAttachments() is still always an empty list.
Upon closer inspection I noticed binary data on a header sent AS THE FILE from jQuery FileUpload. exchange.getIn().getHeader("files[]") is a binary data stream, but the data appears to be mangled... I assume because it is being converted to UTF8 encoding (or visa-versa) before it is set on the header.
So my question is how does a person upload files via camel-jetty? I can not find a single example that works when used in the real world with camel-jetty 2.17.0. All examples used to work on Camel-Jetty 2.3.
What am I doing wrong? Can someone please post a working example of a file upload processor using camel-jetty 2.17?