Method Description
Binary.append()
Append the contents of one binary object onto another
Syntax
binary = Binary.append(sourceObj)
Parameters
The 'Binary.append' method takes 1 parameter:
Name | Type/Value | Range/Length | Description | sourceObj | binary | | Required. A binary object to be appended to the current binary object |
Results
The 'Binary.append' method returns binary:
Type/Value | Range/Length | Description |
binary |
  | |
Remarks This method copies the content of another binary object onto this one. This method can be used to reconstruct a single binary object from a set of 'slices' created using
the 'slice' metnhod. Note that JavaScript itself doesn't handle binary objects so these methods are the
only sensible way of splitting and reconstructing binary data. See the binary object technical note for details Example Assuming we have one big file spread over a set of template files - your can reconstruct the
big file as follows:
function buildFile(arrayFileIDs) {
var bigFile = new Binary;
for (var i=0;i<arrayFileIDs;i++) {
var it = rb.file.get({fileID:arrayFileIDs[i]});
if (it.getNextRow())
bigFile.append(it.fileDef);
}
return bigFile;
}
Note however that this is not particularly efficient in the case where the file is simply being
written out to the client. In this case it's easier simply to stream out the contents as follows:
function sendFile(arrayFileIDs) {
for (var i=0;i<arrayFileIDs;i++) {
var it = rb.file.get({fileID:arrayFileIDs[i]});
if (it.getNextRow())
rb.page.writeraw(it.fileDef);
}
}
|