Namespace: OrionDownload

OrionDownload

Provides a way to download one or many files concurrently, or to monitor other downloads in progress.

Source:

Methods

<static> downloadFile(key, url, path)

Initiate the download of a file from a URL to path.

Parameters:
Name Type Description
key String

A unique value for monitoring/controlling the download, suggest using OrionSystem.generateUniqueKey.

url String

Remote source.

path String

Local destination.

Source:
See:
Example
OrionDownload.downloadFile('000000-000000-00000-0000', 'http://www.example.com/foo.tar.gz', '/Users/dgooden/foo.tar.gz');

<static> setErrorCallback(objectName, callbackName)

Sets a callback to alert you when a download fails.

Parameters:
Name Type Argument Default Description
objectName String <optional>
'window'

Namespace containing method.

callbackName String

Name of method.

Source:
See:
Fires:
Example
OrionDownload.setErrorCallback('', 'downloadErrorCallback');

function downloadErrorCallback(event)
{
   if (event.eventName == 'downloadError')
   {
       var key          = event.key,
           errorMessage = event.errorText;
       
       // ...
   }
}

<static> setFinishCallback(objectName, callbackName)

Sets a callback to alert you when a download has finished. This will not be fired if the download fails or is cancelled.

Parameters:
Name Type Argument Default Description
objectName String <optional>
'window'

Namespace containing method.

callbackName String

Name of method.

Source:
See:
Fires:
Example
OrionDownload.setFinishCallback('', 'downloadFinishCallback');

function downloadFinishCallback(event)
{
   if (event.eventName == 'downloadFinish')
   {
       var key                  = event.key,
           totalBytesDownloaded = event.totalDown;
       
       // ...
   }
}

<static> setProgressCallback(objectName, callbackName)

Sets a callback that will be called by the framework during a file download. Normal starlets will just get information about downloads they initiated, while the connection starlet will see all of them.

Parameters:
Name Type Argument Default Description
objectName String <optional>
'window'

Namespace containing method.

callbackName String

Name of method.

Source:
See:
Fires:
Example
OrionDownload.setProgressCallback('', 'downloadProgressCallback');

function downloadProgressCallback(event)
{
   if (event.eventName == 'downloadProgress')
   {
       for (var key in event.downloads)
       {
           var cur   = event.downloads[key].curBytes,
               total = event.downloads[key].totalBytes;
           
           // ...
       }
   }
}

<static> setResponseCallback(objectName, callbackName)

Sets a callback to get response data from the server after an download.

Parameters:
Name Type Argument Default Description
objectName String <optional>
'window'

Namespace containing method.

callbackName String

Name of method.

Source:
See:
Fires:
Example
OrionDownload.setResponseCallback('', 'downloadResponseCallback');

function downloadResponseCallback(event)
{
   if (event.eventName == 'downloadResponse')
   {
       var key          = event.key,
           responseCode = event.responseCode,
           responseBody = event.responseBody;
       
       // ...
   }
}

<static> stopDownload(key)

Stops a download identified by key.

Parameters:
Name Type Description
key String

Unique identifier of download.

Source:
See:

<static> unsetErrorCallback()

Clears the download error callback, stopping those events from being sent.

Source:
See:

<static> unsetFinishCallback()

Clears the download finish callback, stopping those events from being sent.

Source:
See:

<static> unsetProgressCallback()

Clears the download progress callback, stopping those events from being sent.

Source:
See:

<static> unsetResponseCallback()

Clears the download response callback, stopping those events from being sent.

Source:
See: