Class

DownloadManager

DownloadManager(options)

Download a file from a url
Constructor

# new DownloadManager(options)

Initialize the download manager
Parameters:
Name Type Description
options Object The download manager options
abandonedTimeout Number The time in milliseconds to wait before abandoning a download (default: 30 minutes)
defaultDelayInSeconds Number The default delay in seconds to wait before starting a download (default: 0). This is used when a download is scheduled but the delay is not specified in the options object.
defaultRetryLimit Number The default number of times to retry a download before abandoning it (default: 5)
getDownloadDelay getDownloadDelay The function to use to calculate the delay to assign a download (default: null)
disableUnzip Boolean If true, don't unzip the downloaded zip file (default: false)
downloadManifest Array The list of files to download (default: [])
downloadManifest.delayInSeconds Number The delay in seconds to wait before starting the download (default: 1 minute)
downloadManifest.fileName String The name of the file to download (the file path will be the download directory + this name) (default: The file name from the url)
downloadManifest.url String The url to download the file from
downloadManifest.unzipTo String The path to unzip the downloaded file to
downloadManifest.requestConfig Object The request configuration to use when downloading the file (i.e. the fetch options)
downloadManifest.retryLimit Number The number of times to retry a download before abandoning it (overrides the defaultRetryLimit option)
interval Number The interval in milliseconds at which to download/check for downloads (default: 1 minute)
verbose Boolean If true, print out debug messages (default: false)
workingDirectory String The directory to download files to (default: './downloads')
getManifest getManifest The function to get the download manifest. It will override the downloadManifest option on each interval.
disableImmediateDownload boolean If true, don't download files immediately on init (default: false)

View Source index.js, line 11

Methods

# init()

Initialize the download manager and start the interval

View Source index.js, line 95

# start(filePath, requestConfig, options) → {Promise}

Start a file download
Parameters:
Name Type Description
filePath String The path to save the file to
requestConfig Object The configuration for the request
options Object The options for the download

View Source index.js, line 321

A promise that resolves when the file is downloaded
Promise