ON THIS PAGE
This assetrealizer object contains functions for realizing files (i.e. extracting files from an asset pool and placing them into the standard file directory).
Object Creation
To create an assetrealizer object, you will first need to create an assetpool instance and download files to it using an assetfetcher instance. Then, load the brightsign/assetrealizer
module using the Require()
method, and create an instance of the assetrealizer class using the assetpool instance and the destination directory for realization.
var AssetPoolClass = require("@brightsign/assetpool"); var assetPool = new AssetPoolClass("SD:/pool"); var AssetRealizerClass = require("@brightsign/assetrealizer"); var assetRealizer = new AssetRealizerClass(assetPool, "SD:/");
AssetRealizer
Use this interface to realize assets and perform related functions.
estimateRealizedSize()
Promise<long> estimateRealizedSize(AssetList assets)
Returns the estimated amount of space (in megabytes) that would be taken up if the files specified in the AssetList object are realized.
realize()
Promise<FailureReason> realize(AssetList assets)
Places the files into the destination directory specified in the passed AssetList object. If the pool does not contain the full set of required files, then this method will immediately fail before any files are changed (this method attempts to do as much work as possible before destructively modifying the file system). This method automatically checks the length of the file and any hashes that match the specification. If there is a mismatch, then the affected file is deleted and realization fails. This method indicates success or failure by returning a FailureReason interface.
The BrightSign JavaScript API currently does not have an equivalent to the roAssetPoolFiles object, so JavaScript applications must allow time to realize assets from an asset pool, rather than referring to them directly.
Note
The pool and the destination must be in the same file system.
validateFiles()
Promise<DOMStringList> validateFiles(AssetList assets, DOMStringList options)
Checks the hash of every file in the spec against the corresponding file in the destination path and returns a string list containing each mismatched file name mapped to the reason. The options
parameter is a string list, which can currently support a single option:
"deleteCorrupt"
: Automatically deletes any files that do not match the expected hash. By default, these files are not deleted.
FailureReason
This interface is returned by the realize()
method to indicate the results of the realize operation.
[DOMString] name
: The name of the mismatched file (if the realize operation fails)[bool] ok
: A flag indicating whether the realize operation succeeded or failed[DOMString] reason
: An explanation for a failed realize operation. See the roAssetRealizerEvent page for a list of possible reason strings.