Example
//we have no cookie, so we pass in null
var downloadHandle = siteKiosk.network.fileDownload.download(
"http//your.url",
"/some/local/path",
null,
function(status, localFileName, mediaType) {
//hopefully status = 8, which represents success (see status table)
console.log("Download finished with status "+status);
}
);
//after one second, log the download's progress percentage
setTimeout(function() {
console.log("Download is at "+downloadHandle.getProgress()+" %.");
}, 1000;
Members
-
<static> status :number
-
Download status.
Type:
- number
Properties:
Name Type Default Description pending
number 1 running
number 2 paused
number 4 success
number 8 failed
number 16 unknown
number -1
Methods
-
<static> download(url, path, cookieString, completed) → {siteKiosk.network.fileDownload~downloadHandle}
-
Starts a file download.
Parameters:
Name Type Argument Description url
string The URL to the resource, which should be downloaded path
string <nullable>
The destination file path cookieString
string <nullable>
The Cookie HTTP header completed
siteKiosk.network.fileDownload~downloadCallback A callback, which will be called when the download is complete Returns:
A handle to cancel the download -
<static> getStatus(url) → {number}
-
Gets the download status for a given URL.
Parameters:
Name Type Description url
string The download URl Returns:
The download status- Type
- number
-
<static> removeDownloadByUrlPrefix(urlPrefix, completed)
-
Removes all downloads whose source URL starts with the given URL prefix.
Parameters:
Name Type Description urlPrefix
string The URL prefix completed
siteKiosk.network.fileDownload~removeDownloadCallback The callback which will be called when the operation has been completed
Type Definitions
-
downloadCallback(status, localFileName, mediaType)
-
A callback which will be called when a download has been finished.
Parameters:
Name Type Description status
string The download status (either "success" or "failed") localFileName
string The path to the file mediaType
string The MIME type of the downloaded file -
downloadHandle
-
A handle to cancel the download.
Properties:
Name Type Description cancel
function Function to cancel the download getProgress
function Function to get the progress of the download (in percent) -
removeDownloadCallback()
-
A callback which will be called when an operation to remove downloads has been completed.