Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Panel
borderColor#3D3D3D
bgColor#F4F4F4
titleColor#3D3D3D
borderWidth0
titleBGColor#3D3D3D
borderStylesolid

ON THIS PAGE

Table of Contents
indent20px

The This assetrealizer object allows you to transfer contains functions for realizing files (i.e. extracting files from an asset pool to other locations in the and placing them into the standard file directory).

Code Block
languagejs
titleassetrealizer IDL
collapsetrue
[
    GarbageCollected
] interface AssetRealizer {
    AssetPoolFetcher(AssetPool pool, DOMString path);
    Promise<long> estimateRealizedSize(AssetList assets);
    Promise<FailureReason> realize(AssetList assets);
    Promise<DOMStringList> validateFiles(AssetList assets, DOMStringList options);
};

interface FailureReason {
    attribute DOMString name;
    attribute bool ok;
    attribute DOMString reason;
};

...

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.

Code Block
languagejs
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()
Code Block
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()
Code Block
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.

Note
titleNote

The pool and the destination must be in the same file system.

validateFiles()
Code Block
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