I need to send files to a server which contains multipart/mixed content. For exemple:
------------------------------1b479dca9c3e
Content-Disposition: form-data; name="one_part"
Content-Type: text/xml; charset=utf-8
XX-Project-Type: METADATA
<?xml version="1.0" encoding="utf-8"?>
<My_MSG version="1">
<MSG date="2014-08-20T18:39:59.154326+00:00">
<METADATA mess_id="sd1212sd05AZ">
<CONVERSION>
<FILE name="foo.bar"/>
<FILE name="ping.pong"/>
<FILE name="abc.def"/>
</CONVERSION>
</METADATA>
</MSG>
</My_MSG>
------------------------------1b479dca9c3e
Content-Disposition: form-data; name="one_part"
Content-Type: text/xml; charset=utf-8
XX-Project-Type: METADATA
<?xml version="1.0" encoding="utf-8"?>
<My_MSG version="1">
<MSG date="2015-08-20T19:39:59.154326+00:00">
<METADATA mess_id="az987456321">
<CONVERSION>
<FILE name="bar.foo"/>
<FILE name="pong.ping"/>
<FILE name="def.abc"/>
</CONVERSION>
</METADATA>
</MSG>
</My_MSG>
------------------------------1b479dca9c3e--
As you can see the multipart boudary is already defined into the file to send, so to send it with CURL I use following command:
curl -d @/tmp/exemple.file -XPOST http://myServer:8000/multipartService -H "content-type: multipart/Mixed ; boundary=----------------------------1b479dca9c3e"
But the server does not succeed to handle parts. For the moment I don't have server's logs, but I perform a tcpdump to see what is send to the server:
It seems that spaces and carriage returns are deleted in the send request and it could explain that the request content can't be handle as multipart/mixed by the server...
Do you know how to send my file with multipart/mixed compliant format?
Edit for hanshenrik:
Let curl do the multipart POST itself and let it handle the separator completely by itself instead. If you for example want to post two parts with contents read from two different files, do it like this:
curl -F "part_one=<file1.xml" -F "part_two=<file2.xml" \
http://myServer:8000/multipartService
Insisting?
Then you need to do the whole thing yourself and use --data-binary
.