Hi,

I need to send form data (binary files). With Curl you can do this as
follows:

curl https://reqbin.com/echo/post/form
   -F key1=value1
   -F key2=value2
   -F photo=@photo.png

or

curl https://reqbin.com/echo/post/form
   --form key1=value1
   --form key2=value2
   --form photo=@photo.png

I was first trying to use the HTTP component, but it doesn't seem to
support form data.

Normal headers are converted to HTTP headers, but you can not do name
a header with for example form.headername=headervalue

or attachments that are turned into form data.

My goal is to use a solution with the XML DSL and try to avoid custom
Java code (if possible).

As far as I can see, I have the following options:

1. Vert.x HTTP component seem to have some support for form data (not
extensively documented)

2. Mime-Multipart
(https://camel.apache.org/components/3.20.x/dataformats/mimeMultipart-dataformat.html).
Not really sure how to use it, but as I understand it,
you set the body and attachments and this turned into a mime-multipart
with marshalling. It also needs a dependency on mail, and is somehow
not an independent dataformat.

3. Apache HTTP Client: Create a custom bean/processor that uses the
Apache HTTP client to send the form data.

Has anyone had experience with this? What is the best and easiest way?

Raymond

Reply via email to