Added MIME-Multipart dataformat docs to Gitbook

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/329a8db3
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/329a8db3
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/329a8db3

Branch: refs/heads/master
Commit: 329a8db366d0ec4296f7fc5e15024dc572a49d8b
Parents: 7eca5fc
Author: Andrea Cosentino <anco...@gmail.com>
Authored: Wed Aug 31 09:44:38 2016 +0200
Committer: Andrea Cosentino <anco...@gmail.com>
Committed: Wed Aug 31 09:44:38 2016 +0200

----------------------------------------------------------------------
 .../main/docs/mime-multipart-dataformat.adoc    | 211 +++++++++++++++++++
 1 file changed, 211 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/329a8db3/components/camel-mail/src/main/docs/mime-multipart-dataformat.adoc
----------------------------------------------------------------------
diff --git a/components/camel-mail/src/main/docs/mime-multipart-dataformat.adoc 
b/components/camel-mail/src/main/docs/mime-multipart-dataformat.adoc
new file mode 100644
index 0000000..cfaa0ca
--- /dev/null
+++ b/components/camel-mail/src/main/docs/mime-multipart-dataformat.adoc
@@ -0,0 +1,211 @@
+[[Mime-Multipart-RSSDataformat]]
+MIME-Multipart Dataformat
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+*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.  +
+Furthermore the MIME headers of the multipart are written as part of the
+message body, not as camel headers.
+
+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.
+
+[[MIME-Multipart-Options]]
+Options
+^^^^^^^
+
+// dataformat options: START
+The MIME Multipart dataformat supports 5 options which are listed below.
+
+
+
+{% raw %}
+[width="100%",cols="2s,1m,1m,6",options="header"]
+|=======================================================================
+| Name | Default | Java Type | Description
+| multipartSubType | mixed | String | Specify the subtype of the MIME 
Multipart. Default is mixed.
+| multipartWithoutAttachment | false | Boolean | Defines whether a message 
without attachment is also marshaled into a MIME Multipart (with only one body 
part). Default is false.
+| headersInline | false | Boolean | Defines whether the MIME-Multipart headers 
are part of the message body (true) or are set as Camel headers (false). 
Default is false.
+| includeHeaders |  | String | A regex that defines which Camel headers are 
also included as MIME headers into the MIME multipart. This will only work if 
headersInline is set to true. Default is to include no headers
+| binaryContent | false | Boolean | Defines whether the content of binary 
parts in the MIME multipart is binary (true) or Base-64 encoded (false) Default 
is false.
+|=======================================================================
+{% endraw %}
+// dataformat options: END
+
+[[MIME-Multipart-MessageHeadersmarshal]]
+Message Headers (marshal)
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+[width="100%",cols="20%,20%,60%",options="header",]
+|=======================================================================
+|Name |Type |Description
+
+|Message-Id |String |The marshal operation will set this parameter to the 
generated MIME
+message id if the "headersInline" parameter is set to false.
+
+|MIME-Version |String |The marshal operation will set this parameter to the 
applied MIME
+version (1.0) if the "headersInline" parameter is set to false.
+
+|Content-Type |String |The content of this header will be used as a content 
type for the
+message body part. If no content type is set, "application/octet-stream"
+is assumed. After the marshal operation the content type is set to
+"multipart/related" or empty if the "headersInline" parameter is set to
+true.
+
+|Content-Encoding |String |If the incoming content type is "text/*" the 
content encoding will be
+set to the encoding parameter of the Content-Type MIME header of the
+body part. Furthermore the given charset is applied for text to binary
+conversions.
+|=======================================================================
+
+[[MIME-Multipart-MessageHeadersunmarshal]]
+Message Headers (unmarshal)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+[width="100%",cols="20%,20%,60%",options="header",]
+|=======================================================================
+|Name |Type |Description
+
+|Content-Type |String |If this header is not set to "multipart/*" the 
unmarshal operation will
+not do anything. In other cases the multipart will be parsed into a
+camel message with attachments and the header is set to the Content-Type
+header of the body part, except if this is application/octet-stream. In
+the latter case the header is removed.
+
+|Content-Encoding |String |If the content-type of the body part contains an 
encoding parameter this
+header will be set to the value of this encoding parameter (converted
+from MIME endoding descriptor to Java encoding descriptor)
+
+|MIME-Version |String |The unmarshal operation will read this header and use 
it for parsing the
+MIME multipart. The header is removed afterwards
+|=======================================================================
+
+[[MIME-Multipart-Examples]]
+Examples
+^^^^^^^^
+
+[source,java]
+-----------------------------------
+from(...).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*
+
+[source,java]
+-------------------------------------------------------------------------------
+Content-Type=multipart/mixed; \n boundary="----=_Part_0_14180567.1447658227051"
+Message-Id=<...>
+MIME-Version=1.0
+-------------------------------------------------------------------------------
+
+-------------------------
+The message body will be:
+-------------------------
+
+*Camel Message Body*
+
+[source,java]
+----------------------------------------------------------------
+------=_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--
+----------------------------------------------------------------
+
+A message with the header Content-Type set to "text/plain" sent to the
+route
+
+[source,java]
+------------------------------------------------------------------------------------
+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*
+
+[source,java]
+----------------------------------------------------------------
+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
+----------------------------------------------------------------
+
+[[MIME-Multipart-Dependencies]]
+Dependencies
+^^^^^^^^^^^^
+
+To use MIME-Multipart in your Camel routes you need to add a dependency
+on *camel-mail* which implements this data format.
+
+If you use Maven you can just add the following to your pom.xml:
+
+[source,xml]
+-----------------------------------------------------------------------------------
+<dependency>
+  <groupId>org.apache.camel</groupId>
+  <artifactId>camel-mail</artifactId>
+  <version>x.x.x</version> <!-- use the same version as your Camel core 
version -->
+</dependency>
+-----------------------------------------------------------------------------------

Reply via email to