Player APIs (BrightScript & Ja...
JavaScript APIs
assetpool
18min
the assetpool object represents a directory on a storage device used to store downloaded assets see the asset pool https //docs brightsign biz/display/doc/brightsign+asset+pool overview for more general information and examples assetpool idl interface assetpool { assetpool(string poolpath); promise\<void> protectassets(string assetcollectionname, assetlist assets); promise\<void> unprotectassets(string assetcollectionname); promise\<void> reservestorage(long reservedstorageinbytes); promise\<void> setmaximumpoolsize(long? maximumpoolsizeinbytes); promise\<long> getpoolsize(); promise\<assetvalidationresult> validate(assetlist assets, assetvalidationoptions options); promise\<assetqueryresult> queryfiles(assetlist assets); promise\<bool> areassetsready(assetlist assets); }; interface assetinfo { attribute string name; attribute string link; \[optional] attribute long size; \[optional] attribute assethash hash; \[optional] attribute string changehint; \[optional] attribute assetfetchauthentication? auth; \[optional] attribute assetfetchheaders? headers; }; interface assethash { attribute string method; attribute string hex; }; interface assetfetchauthentication { \[optional] attribute string user; \[optional] attribute string password; }; interface assetfetchheaders { }; interface assetvalidationoptions { attribute deletecorrupt; }; interface assetqueryresult { attribute string name; attribute bool present; }; interface assetvalidationresult { attribute string name; attribute string reason; }; object creation to create an assetpool object, first load the brightsign/assetpool module using the require() method then create an instance of the assetpool class with a string value specifying the pool path you must create only one assetpool instance per pool path this means that it is not possible to safely share a single pool path between brightscript and javascript code const assetpoolclass = require("@brightsign/assetpool"); let assetpool = new assetpoolclass("sd /pool"); assetpool use this interface to perform operations on the asset pool protectassets() promise\<void> protectassets(string assetcollectionname, assetlist assets) requests that a set of files in the asset pool be protected from deletion when the system software needs to prune files from the pool to make space the passed assetcollectionname is used to reference the set of files if their protection needs to be removed later using the unprotectassets() method protection only affects this assetpool instance and the other objects that use it you must protect all the assets you care about before performing any operation that might prune files from the pool in order to be sure that the assets you still need are not pruned this setting is not persistent beyond the lifetime of the assetpool instance unprotectassets() promise\<void> unprotectassets(string assetcollectionname) removes protection from a set of files that have been protected by passing the corresponding assetcollectionname to the the protectassets() method reservestorage() promise\<void> reservestorage(long reservedstorageinbytes) operations on this assetpool instance, and any other assetpoolfetcher and assetrealizer instances using it, will attempt to keep the specified amount of space free on the storage device containing the pool as other files are written to the storage device, the maximum size occupied by the pool will be reduced to compensate this setting is not stored persistently in the pool, so the method must be called each time an assetpool object is created setmaximumpoolsize() promise\<void> setmaximumpoolsize(long? maximumpoolsizeinbytes) specifies the maximum size of the asset pool this method is more resource intensive than reservestorage() , but it is useful when creating multiple pools on a storage device to ensure they don't grow unevenly this setting is not stored persistently in the pool, so the method must be called each time an assetpool object is created getpoolsize() promise\<long> getpoolsize() returns the current size of the asset pool in bytes it is necessary to walk the pool directory structure looking at every asset file to do this, which may slow down other access to the storage device this method should not be called regularly in production code validate() promise\<assetvalidationresult> validate(assetlist assets, assetvalidationoptions options) recalculates the hashes of every file in the pool and compares them with the expected values in the passed assetlist this means every asset file needs to be read in its entirety which may take a long time and may slow down other access to the storage device this method can be used to detect storage and file system corruption this method returns an assetvalidationresult interface containing validation results for each file the second parameter is an assetvalidationsoptions interface specifying validation options the only option currently supported indicates whether any assets with mismatched hashes are automatically deleted the default behaviour is to leave such asset files in place queryfiles() promise\<assetqueryresult> queryfiles(assetlist assets) determines whether the specified files are present in the asset pool this method returns an assetqueryresult interface containing query results this method is normally only useful for debugging during development areassetsready() promise\<bool> areassetsready(assetlist assets) returns true if every asset in the assetlist is present in the asset pool assetinfo this interface represents a single asset file that may be in the pool may not yet be in the pool each asset has a subset of the following properties name string string the name that can be used to look up the asset for a file to be realized, it must have a valid filename without any slashes asset names must be unique within an asset collection, but different asset collections may use the same asset name to refer to the same asset in the pool or a different asset in the pool asset names are not stored in the pool, the only way to refer to an asset by name is using an asset collection link string string the uri that can be used by assetpoolfetcher to download the file http, https, ftp and file uris are supported size long long optional optional the file length (in bytes) if known hash assethash assethash optional optional a hash interface specifying the hash algorithm and hash value of the file if no hash is provided then one is created automatically from the link and changehint changehint string string optional optional an arbitrary value that can be used by the client to specify that a file has changed even when the hash value and download url remain the same this is mostly useful when the hash is not known but the provider of the asset collection can tell when the content has changed for example, mediarss feeds often provide a guid for the content auth assetfetchauthentication assetfetchauthentication ? ? optional optional an assetfetchauthentication interface specifying the credentials to use when downloading the asset by default, credentials are inherited from the docid\ hg03eush xkkpfofwdgcz instance used to download the asset headers assetfetchheaders? assetfetchheaders? optional optional by default, the http headers specified via the headers property passed to the s tart method will be used for each asset the use of these headers can be disabled for a particular asset by setting this property to null this is useful if a particular subset of assets are retrieved from somewhere else that does not require authentication it is not currently possible to provided specific headers for a single asset assethash this interface contains hash information about the file method string string the hash algorithm accepted values include "sha1", "sha224", "sha256", "sha384", "sha512", "md5" and "besha1" "besha1" is a custom hash algorithm that is only useful for referring to large assets that are stored remotely and its use is not recommended hex string string the hash value in hexadecimal format assetfetchauthentication this interface contains authentication information for downloading files user string string optional optional the user name for authentication password string string optional optional the password for authentication assetvalidationoptions this interface contains validation options for the validate() method deletecorrupt a flag specifying whether corrupt files should be deleted during validation assetqueryresult this interface is returned by the queryfiles() method each entry in the list contains the following parameters name string string the name of the queried file present bool bool a flag indicating whether the queried file exists in the asset pool assetvalidationresult this interface is returned by the validate() method each entry in the list contains the following parameters name string string the name of the checked file reason string string an explanation for a failed validation