Since we're on a major migration process of this website, some component documents here are out of sync right now. In the meantime you may want to look at the early version of the new website
https://camel.apache.org/staging/
We would very much like to receive any feedback on the new site, please join the discussion on the Camel user mailing list.
Available as of Camel 2.17 This data format that can convert a Camel message with attachments into a Camel message having a MIME-Multipart message as message body (and no attachments). The use case for this is to enable the user to send attachments over endpoints that do not directly support attachments, either as special protocol implementation (e.g. send a MIME-multipart over an HTTP endpoint) or as a kind of tunneling solution (e.g. because camel-jms does not support attachments but by marshalling the message with attachments into a MIME-Multipart, sending that to a JMS queue, receiving the message from the JMS queue and unmarshalling it again (into a message body with attachments). The marshal option of the mime-multipart data format will convert a message with attachments into a MIME-Multipart message. If the parameter "multipartWithoutAttachment" is set to true it will also marshal messages without attachments into a multipart message with a single part, if the parameter is set to false it will leave the message alone. MIME headers of the mulitpart as "MIME-Version" and "Content-Type" are set as camel headers to the message. If the parameter "headersInline" is set to true it will also create a MIME multipart message in any case. The unmarshal option of the mime-multipart data format will convert a MIME-Multipart message into a camel message with attachments and leaves other messages alone. MIME-Headers of the MIME-Multipart message have to be set as Camel headers. The unmarshalling will only take place if the "Content-Type" header is set to a "multipart" type. If the option "headersInline" is set to true, the body is always parsed as a MIME message.As a consequence if the message body is a stream and stream caching is not enabled, a message body that is actually not a MIME message with MIME headers in the message body will be replaced by an empty message. Up to Camel version 2.17.1 this will happen all message bodies that do not contain a MIME multipart message regardless of body type and stream cache setting. Options
Message Headers (marshal)
Message Headers (unmarshal)
Examplesfrom(...).marshal().mimeMultipart() With a message where no Content-Type header is set, will create a Message with the following message Camel headers: Camel Message Headers Content-Type=multipart/mixed; \n boundary="----=_Part_0_14180567.1447658227051" Message-Id=<...> MIME-Version=1.0 The message body will be: Camel Message Body ------=_Part_0_14180567.1447658227051 Content-Type: application/octet-stream Content-Transfer-Encoding: base64 Qm9keSB0ZXh0 ------=_Part_0_14180567.1447658227051 Content-Type: application/binary Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="Attachment File Name" AAECAwQFBgc= ------=_Part_0_14180567.1447658227051--
from("...").marshal().mimeMultipart("related", true, true, "(included|x-.*)", true); will create a message without any specific MIME headers set as Camel headers (the Content-Type header is removed from the Camel message) and the following message body that includes also all headers of the original message starting with "x-" and the header with name "included": Camel Message Body Message-ID: <...> MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_0_1134128170.1447659361365" x-bar: also there included: must be included x-foo: any value ------=_Part_0_1134128170.1447659361365 Content-Type: text/plain Content-Transfer-Encoding: 8bit Body text ------=_Part_0_1134128170.1447659361365 Content-Type: application/binary Content-Transfer-Encoding: binary Content-Disposition: attachment; filename="Attachment File Name" [binary content] ------=_Part_0_1134128170.1447659361365
|