This script transforms the current body to base64. Commonly used if target systems expect files to be encoded into base64 rather than a stream or binary format.

import com.sap.gateway.ip.core.customdev.util.Message
 
def Message processData(Message message) {
    // Get the message body as a string
    def body = message.getBody(String.class)
 
    // Encode the string to base64
    def base64Encoded = body.bytes.encodeBase64().toString()
 
    // Set the encoded string as the new message body
    message.setBody(base64Encoded)
 
    return message
}