2

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?

Community
  • 1
  • 1
th317erd
  • 304
  • 3
  • 11
  • Why not show the NPE fix and report it to Apache Camel: http://camel.apache.org/support.html – Claus Ibsen Apr 16 '16 at 05:50
  • Honestly because this is so big I figured there is no way it could have been an oversight over at apache (or eclipse jetty) and figured I must be the one doing something wrong. – th317erd Apr 18 '16 at 01:02
  • @th317erd Looks like the only supported Content-Type is application/octet-stream, otherwise the attachment is ignored. By the way, the already mentioned NPE is caused by the same `if` which checks for Content-Type. The code in question: https://github.com/apache/camel/blob/c134e5a6e104c60ddcd198341718a37f0a4401ba/components/camel-jetty9/src/main/java/org/apache/camel/component/jetty9/AttachmentHttpBinding.java#L53 – rpozarickij Apr 18 '16 at 08:28
  • Reported :) https://issues.apache.org/jira/browse/CAMEL-9874 – rpozarickij Apr 18 '16 at 09:08
  • Thank you much all of you! :) – th317erd Apr 18 '16 at 18:17

0 Answers0