Hello,

I was able to solve my base64 problems as:
ContentType contentType = new ContentType (dh.getContentType());
if (contentType.match("image/*")) { // convert to base64 and add 
Content-Transfer-Encoding attribute
byte[] attachmentData = 
exchange.getContext().getTypeConverter().convertTo(byte[].class, 
dh.getInputStream());
theAttachmentInXml.appendChild(theParentNode.getOwnerDocument().createCDATASection(javax.xml.bind.DatatypeConverter.printBase64Binary(attachmentData)));
theAttachmentInXml.setAttribute("Content-Transfer-Encoding", "base64");
} else {
String attachmentData = 
exchange.getContext().getTypeConverter().convertTo(String.class, 
dh.getInputStream());
theAttachmentInXml.appendChild(theParentNode.getOwnerDocument().createCDATASection(attachmentData));
}

--
vriendelijke groeten,
Ronny Aerts - Intris nv - Wapenstilstandlaan 47, 2600 Berchem, Belgiƫ
R&D Integration Architect
Prince II certified
Tel: +32-3-326.50.75

-----Original Message-----
From: Claus Ibsen [mailto:claus.ib...@gmail.com]
Sent: woensdag 22 januari 2014 19:58
To: users@camel.apache.org
Subject: Re: convert attachment to base64

Hi

The data format works on the message body content only.

If you want to encode some attachments only. I suggest to write a piece of java 
code that does that.
You can use commons-codec for the base64. But I think in some of the newer JDKs 
its out of the box.

On Wed, Jan 22, 2014 at 5:34 PM, Ronny Aerts <ronny.ae...@intris.be> wrote:
> Hello,
>
> I have a camel component written in java. At a certain point, I need to 
> convert the content of an attachment (or body) to a base64 encoding string. 
> Can this be done with the camel base64 dataformat? And if yes, how do I do 
> this in java?
>
> --
> Kind regards,
> Ronny Aerts<mailto:ronny.ae...@intris.be> - Intris nv -
> Wapenstilstandlaan 47, 2600 Berchem, Belgium R&D Integration Architect
> Prince II certified
> Tel: +32-3-326.50.75
>
>
> Intris nv
> Wapenstilstandlaan 47
> B-2600 Berchem
>         Tel.  +32 3 326 50 75
> Fax  +32 3 326 42 23
> www.intris.be<http://www.intris.be/>
>
> DISCLAIMER
> This is an e-mail from Intris. The information contained in this 
> communication is intended solely for use by the individual or entity to whom 
> it is addressed.
> Use of this communication by others is prohibited. If the e-mail message was 
> sent to you by mistake, please notify 
> supp...@intris.be<mailto:supp...@intris.be>, destroy it without reading, 
> using, copying or disclosing its contents to any other person.
> We accept no liability for damage related to data and/or documents which are 
> communicated by electronic mail.



--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen Make your Camel 
applications look hawt, try: http://hawt.io
Intris nv
Wapenstilstandlaan 47
B-2600 Berchem
        Tel.  +32 3 326 50 75
Fax  +32 3 326 42 23
www.intris.be<http://www.intris.be/>

DISCLAIMER
This is an e-mail from Intris. The information contained in this communication 
is intended solely for use by the individual or entity to whom it is addressed.
Use of this communication by others is prohibited. If the e-mail message was 
sent to you by mistake, please notify 
supp...@intris.be<mailto:supp...@intris.be>, destroy it without reading, using, 
copying or disclosing its contents to any other person.
We accept no liability for damage related to data and/or documents which are 
communicated by electronic mail.

Reply via email to