Contact Us 1-800-596-4880

toBase64

toBase64(content: Binary): String

Transforms a binary value into a Base64 string.

Parameters

Name Description

content

The binary value to transform.

Example

This example transforms a binary value into a Base64 encoded string. In this case, the binary value represents an image.

Source

%dw 2.0

import dw::Crypto
import toBase64 from dw::core::Binaries

var emailChecksum = Crypto::MD5("achaval@gmail.com" as Binary)
var image = readUrl(log("https://www.gravatar.com/avatar/$(emailChecksum)"), "application/octet-stream")

output application/json
---
toBase64(image)

Output

This example outputs a Base64 encoded string. The resulting string was shortened for readability purposes:

"/9j/4AAQSkZJRgABAQEAYABgAAD//..."