11.1.8 AsBase64String Method

Encodes the binary data represented by this XPRIM_Binary using Base64 encoding.

Base64 encoding is one of the commonly used binary-to-text encoding. You would encode your byte into a string when you need to include binary data as part of a text transmission, for example in a JSON string.

For more information about Base64 encoding, see this Wikipedia article.

In terms of functionality, Base64 encoding is equivalent to Hex encoding, but Base64 produces a shorter string. You should always use Base64 encoding instead of hex (unless you need to maintain compatibility with existing data)

Input Arguments

None

Output Arguments

Name

Type

Mandatory

Description

ErrorInfo

XPRIM_ErrorInfo

No

Indicates an error that might have occurred.

 

Return Value

The Base64-encoded string representation of the binary data.

Examples

Read the content of a file and insert into a JSON

Define_Com Class(#XPRIM_Binary) Name(#File)

Define_Com Class(#XPRIM_JsonWriter) Name(#Writer)

. . .

#File.FromFile Path('/tmp/file.bin')

#Writer.WriteString Name('file') Value(#File.AsBase64String)