cancel
Showing results for 
Search instead for 
Did you mean: 

convert message content to base64 code format.

Former Member
0 Kudos

Hi,

While sending the file to the target directory ,need to convert the content to base64 code format.How we can achieve this.

Regards,

Hymavathi

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

You can take the entire input that you need to convert to base64 to this UDF which takes a single string array as input say var1[ ] and it has a single ResultList item result as output which contains the BASE64 encoded output

The complete code is as follows:


public void encode(String var1[],ResultList result,Container container) throws StreamTransformationException
{
BASE64Encoder encoder=new BASE64Encoder();
String s=null;
byte[] byteArr=null;
try
 {
   byteArr=encoder.encodeBuffer(var1[0]);
  }
catch(Exception e)
{}
s=new String(byteArr);
result.addValue(s);
}

You can use the same basic code in a java mapping as well to suit your requirement after the message mapping is done.

Hope the code helps you .

Thanks

Biswajit

Edited by: 007biswa on Mar 3, 2011 7:54 PM

Former Member
0 Kudos

I think file adapter does not support conversion to base 64. Now you have 2 options:

1. Write a adapter module and use it in your CC

2. Write a script which converts UTF8 to Base 64 and use the script in your CC.

Following link will help :