The BinaryFile component is used to write binary information to files, read binary files and read blocks from binary files. The component reads a file into a Binary object, or writes a Binary object to a file.
In the following code, each file attachment in the process instance in written to a file:
for each a in ProcessInstance.attachments do
BinaryFile.writeFromBinaryTo(data : a.contents,
name : a.fileName,
append : false)
end
In this example, the BinaryFile component is used to read the entire contents of a binary file, then create a process instance attachment:
binContent = BinaryFile.readToBinaryFrom(name : "myBinaryFile.bin")
Attachment.create(contents : binContent,
name : "myBinaryFile.bin",
description : "This is an example attachment")
In this example, the BinaryFile component is used to append binary information to a file:
binarytext = Binary(text : "More Info to be added", encoding : "UTF8")
binFileLength = BinaryFile.writeFromBinaryTo(data : binarytext, name : "myBinaryFile.bin", append : true)
display ("Binary File Length / Added info : " + binFileLength)
In this example, the BinaryFile component is used to read the first 10 bytes of a file:
binContent = BinaryFile.readBlockFrom(name : "myBinaryFile.bin", maxBlockSize : 10) display "Returned Binary Block Length : " + length(binContent) display "Returned Binary Information Block: " + String(binary : binContent, encoding : "UTF8")