Skip to content

Binary Node Path Syntax

A Binary message is an opaque byte blob used to ferry non-textual content (PDFs, images, encrypted payloads) through QIE without inspecting its internal structure. Because the message body has no parsed structure, Binary supports only the root node path (/); any other node path throws a MessageModelException with the text Invalid node path: '...'.

Operation Binary support
getNode('/') Returns the entire message body as a String decoded using the message's configured encoding.
checkNodeExists('/') Returns true when the message body is non-empty.

Examples

Read the message body as a decoded string (uses the message's configured encoding):

var content = source.getNode('/');

Read the raw bytes:

var bytes = source.getBytes();

Get the number of bytes:

var size = message.length();

Replace the message bytes:

message.setBytes(newByteArray);

In practice, the most common use of a Binary message is to write its content out to a file, either via a File Sender destination node, or from a custom script using qie.writeFile(). Because qie.writeFile() accepts a byte[] directly, the bytes returned by source.getBytes() can be written without any decoding step:

var bytes = source.getBytes();
qie.writeFile('/tmp/output.pdf', bytes, true);

The third argument (true) creates any missing directories in the destination path.