🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators BlobToBase64
This page was created by Lars.olofsson on 2020-06-11. Last edited by Wikiadmin on 2026-07-29.

You can use BlobToBase64 in OCL to convert a single Blob (binary) value to a Base64-encoded string, for example when you need to handle binary content as text.

Syntax

blobValue.BlobToBase64

The operator is evaluated on one Blob value and returns one string.

Input Expression Result
One Blob value blobValue.BlobToBase64 One Base64-encoded string

Convert one Blob

Use BlobToBase64 directly when your expression resolves to one object and one Blob attribute.

Customer.allInstances()->first().ProfilePicture.BlobToBase64

In this example:

  1. Customer.allInstances() produces a collection of Customer objects.
  2. first() selects one Customer from that collection.
  3. ProfilePicture is the selected customer's Blob attribute.
  4. BlobToBase64 converts that Blob value to one Base64 string.

The result is a single string, not a collection.

Choose the object deliberately

first() is appropriate only when any one object is sufficient for the expression you are testing. If you need the picture for a particular customer, make the expression resolve to that customer before calling BlobToBase64. Do not treat first() as a way to identify a specific customer.

Convert a collection of Blobs

You cannot apply BlobToBase64 to the Customer collection itself. Use collect to evaluate the conversion once for each Customer.

Customer.allInstances()->collect(x | x.ProfilePicture.BlobToBase64)

In this example, collect iterates over every Customer. For each Customer, it converts ProfilePicture to Base64. The result is a new collection containing one Base64 string for each converted Blob.

Requirement Pattern Result shape
Convert the Blob from one selected object object.BlobAttribute.BlobToBase64 One string
Convert the Blob from every object in a collection x.BlobAttribute.BlobToBase64) Collection of strings

Use the Base64 result

Base64 represents binary content as a string. Use the returned string where an expression requires text. To convert Base64 text back to a Blob, use Base64ToBlob. To create Base64 from string content rather than from a Blob, see StringToBase64.

For a compression workflow, SysSingleton.Deflate accepts and returns Blob values; convert the resulting Blob with BlobToBase64 when you need a Base64 string.

See also