Page tree
Skip to end of metadata
Go to start of metadata

ON THIS PAGE

The assetpoolfetcher object allows for downloading files to an asset pool (which is represented in JavaScript as an assetpool instance).

assetpoolfetcher IDL
[
    GarbageCollected
] interface AssetPoolFetcher : EventTarget {
    AssetPoolFetcher(AssetPool pool);
    Promise<void> start(AssetList list, AssetPoolFetcherParams assetPoolParams[optional]);
    Promise<void> cancel();
    EventListener fileevent;
    EventListener progressevent;
};

interface FileEvent : Event {
    attribute DOMString fileName;
    attribute int index;
    attribute int responseCode;
    attribute DOMString error;
};

interface ProgressEvent : Event {
    attribute DOMString fileName;
    attribute int index;
    attribute int total;
    attribute long currentFileTransferred;
    attribute long currentFileTotal;
};

interface AssetPoolFetcherParams {
    attribute Authentication auth;
    attribute bool enableUnsafeAuthentication;
    attribute bool enableUnsafeProxyAuthentication;
    attribute bool enableEncodings;
    attribute bool enablePeerVerification;
    attribute bool enableHostVerification;
    attribute DOMString certificatesFile;
    attribute HeaderList headers;
    attribute DOMString proxy;
    attribute DOMStringList proxyBypassList;
    attribute unsigned int progressInterval;
    attribute unsigned int fileRetryCount;
    attribute DOMString relativeLinkPrefix;
    attribute DOMString interfaceName;
    attribute MinTransferRate minimumTransferRate;
    attribute double maximumTransferRate;
    attribute bool onlyRequestCache;
};

interface Authentication {
    attribute DOMString username;
    attribute DOMString password;
};

interface HeaderList {
    attribute DOMString name;
    attribute DOMString value;
};

interface MinTransferRate {
    attribute int bytesPerSecond;
    attribute int periodInSeconds;
};

Object Creation

To create an assetpoolfetcher object, you will first need to create an assetpool instance. Then, load the brightsign/assetpoolfetcher module using the Require() method, and create an instance of the assetpoolfetcher class using the assetpool instance.

var AssetPoolClass = require("@brightsign/assetpool");
var assetPool = new AssetPoolClass("SD:/pool");
 
var AssetPoolFetcherClass = require("@brightsign/assetpoolfetcher");
var assetPoolFetcher = new AssetPoolFetcherClass(assetPool);

AssetPoolFetcher

This interface allows you start or stop the asset fetcher and receive events related to the fetching process.

Events

  • [EventListener] fileevent: An event associated with an individual file download. Results are returned as a FileEvent interface.
  • [EventListener] progressevent: An event associated with the overall asset fetching process. Results are returned as a ProgressEvent interface.

Methods

start()
Promise<void> start(AssetList list, AssetPoolFetcherParams assetPoolParams[optional])

Begins fetching the files specified in the passed AssetList interface. The fetching process is configured with the passed AssetPoolFetcherParams interface. The start() promise returns when the asset-fetching process is complete. Alternatively, the promise will be rejected if the assetpoolfetcher instance has already been started.

cancel()
Promise<void> cancel()

Cancels the asset-fetching process.

FileEvent

This interface contains information about a file-transfer attempt.

  • [DOMString] fileName: The name of the file being downloaded
  • [int] index: The zero-based index of the file in the AssetList object
  • [int] responseCode: The protocol response code associated with the event. The following codes indicate success:
    • 200: Successful HTTP transfer
    • 226: Successful FTP transfer
    • 0: Successful local file transfer

    Note

    There are also numerous error codes in case of failure; see here for a non-exhaustive list. 

  • [DOMString] error: The text version of the responseCode if it is an error code.

ProgressEvent

This interface contains information about the asset-fetching process.

  • [DOMString] fileName: The name of the file currently being downloaded
  • [int] index: The zero-based index of the current file in the AssetList object
  • [int] total: The total number of files in the AssetList object
  • [long] currentFileTransferred: The amount (in megabytes) of the current file that has been downloaded
  • [long] currentFileTotal: The total size (in megabytes) of the current file

AssetPoolFetcherParams

This interface contains configuration parameters for the asset-fetcher process.

  • [Authentication] auth: An Authentication interface specifying the credentials to use when downloading the asset
  • [bool] enableUnsafeAuthentication: A flag enabling basic HTTP authentication. HTTP authentication uses an insecure protocol, which might allow others to easily determine the password. The assetpoolfetcher object will still prefer the stronger digest HTTP if it is supported by the server. If this parameter is false (which is the default setting), it will refuse to provide passwords via basic HTTP authentication, and any requests requiring this authentication will fail.
  • [bool] enableUnsafeProxyAuthentication: A flag enabling basic HTTP authentication against proxies. HTTP authentication uses an insecure protocol, which might allow others to easily determine the password. If this parameter is false, it will refuse to provide passwords via basic HTTP authentication, and any requests requiring this authentication type will fail. Unlike enableUnsafeAuthentication, this parameter is set to true by default. 
  • [bool] enableEncodings: A flag enabling HTTP compression, which communicates to the server that the system can accept any encoding that the assetpoolfetcher instance is capable of decoding by itself (this behavior is enabled by default). Supported encodings currently include "deflate" and "gzip", which allow for transparent compression of responses. Clients of the assetpoolfetcher instance see only the decoded data and are unaware of the encoding being used.
  • [bool] enablePeerVerification: A flag that enables checking of TLS/SSL certificates. This parameter is set to true by default. Disabling peer verficiation allows you to bypass an expired certificate check.
  • [bool] enableHostVerification: A flag that enables checking of the TLS/SSL certificate for the correct hostname. This parameter is set to true by default. Disabling host verification allows you to accept a certificate being sent for the wrong hostname.

    Important

    Peer verficiation and host verification are important security checks that prevent "man-in-the-middle" attacks. These features should only be disabled after careful consideration of the security implications.

  • [DOMString] certificatesFile: The filename of an alternative set of CA certificates for the connection. This method is useful if the connection certificates are signed by a CA that is not on the the default trusted list (for example, if your organization uses a private CA hierarchy that is not signed by a well known root CA). This file replaces the default list, so the passed certificate file must contain all acceptable CA certificates required for the connection.
  • [HeaderList] headers: A list of headers that will be passed to HTTP requests made by the assetpoolfetcher instance.
  • [DOMString] proxy: The name or address of the proxy server that will be used by the assetpoolfetcher instance. The proxy string should be formatted as "http://user:password@hostname:port". It can contain up to four "*" characters; each "*" character can be used to replace one octet from the current IP address. For example, if the IP address is currently 192.168.1.2, and the proxy is set to "proxy-*-*", then the player will attempt to use a proxy named "proxy-192.168".
  • [DOMStringList] proxyBypassList: A list of hosts to exempt from the proxy setting. The list should consist of one or more hostnames. The assetpoolfetcher instance will attempt to reach the specified hosts directly rather than using the proxy that has been specified with the proxy parameter. For example, the hostname "example.com" would exempt "example.com", "example.com:80", and "www.example.com" from the proxy setting.
  • [unsigned int] progressInterval: The interval (in seconds) between progress events when an individual file is being downloaded. Setting the interval to null disables all progress events. Setting the interval to 0 specifies that events should be generated as often as possible, though this will slow down the transfer process. If the interval is set to 0 or any positive integer, events will always be generated at the start and end of the file download irrespective of elapsed time. The default interval is 300 seconds.
  • [unsigned int] fileRetryCount: The maximum number of times each file download will be retried before moving on to the next file download. The default retry count is five.
  • [DOMString] relativeLinkPrefix: A prefix that will be appended to the front of relative links in the AssetList object. Normally, this method is used to make file:/// URIs drive agnostic, but it can also be used to reduce the size of the sync spec if all files are stored in the same place. Non-relative links are not affected by this method.
  • [DOMString] interfaceName: A string specifying which network interface the assetpoolfetcher instance should use to transmit the HTTP request ("ethernet" or "wifi"). The default behavior is to send requests using the most appropriate network interface, which may depend on the routing metric configured via the networkconfiguration object. If both interfaces are on the same layer 2 network, this method may not work as expected due to the Linux weak-host model.
  • [MinTransferRate] minimumTransferRate: A MinTransferRate interface specifying the average minimum transfer rate for file downloads. If a file transfer falls below this rate, it will be terminated.
  • [double] maximumTransferRate: The maximum transfer rate for file downloads. The source data rate isn't under the direct control of the BrightSign player, but download rates should average below the specified value over time. 
  • [bool] onlyRequestCache

Authentication

This interface contains authentication information for downloading files.

  • [DOMString] user: The user name for authentication
  • [DOMString] password: The password for authentication

HeaderList

This interface contains a list of headers to pass to a file download URL. Each entry in the list contains the following parameters:

  • [DOMString] name: The header name
  • [DOMString] value: The header value

MinTransferRate

The values in this interface are used to calculate the minimum transfer rate.

  • [int] bytesPerSecond: The transfer rate below which, when it is averaged over the periodInSeconds, the file transfer will be terminated
  • [int] periodInSeconds: The time frame over which the bytesPerSecond measurement is averaged

Note

If the transfer is over the Internet, you may not want to set the periodInSseconds to a small number in case network problems cause temporary drops in performance. For large file transfers and a small bytesPerSeocnd limit, averaging fifteen minutes or more may be appropriate.



  • No labels