Namespace: OrionUpload

OrionUpload

Provides a way to upload one or many files concurrently, or to monitor other uploads in progress.

Source:

Methods

<static> setErrorCallback(objectName, callbackName)

Sets a callback to alert you when an upload fails.

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

Namespace containing method.

callbackName String

Name of method.

Source:
See:
Fires:
Example
OrionUpload.setErrorCallback('', 'uploadErrorCallback');

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

<static> setFinishCallback(objectName, callbackName)

Sets a callback to alert you when an upload has finished. This will not be fired if the upload 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
OrionUpload.setFinishCallback("","uploadFinishCallback");

function uploadFinishCallback(event)
{
   if (event.eventName == 'uploadFinish')
   {
       var key                = event.key,
           totalBytesUploaded = event.totalUploaded;
       
       // ...
   }
}

<static> setProgressCallback(objectName, callbackName)

Sets a callback that will be called by the framework during a file upload. Normal starlets will just get information about uploads 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
OrionUpload.setProgressCallback('', 'uploadProgressCallback');

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

<static> setResponseCallback(objectName, callbackName)

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

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

Namespace containing method.

callbackName String

Name of method.

Source:
See:
Fires:
Example
OrionUpload.setResponseCallback('', 'uploadResponseCallback');

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

<static> stopUpload(key)

Stops an upload identified by key.

Parameters:
Name Type Description
key String

Unique identifier of upload.

Source:
See:

<static> unsetErrorCallback()

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

Source:
See:

<static> unsetFinishCallback()

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

Source:
See:

<static> unsetProgressCallback()

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

Source:
See:

<static> unsetResponseCallback()

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

Source:
See:

<static> uploadFile(key, url, fileFormValue, fileArray, formValues)

Initiate an upload of a file to url, using the formValue (if needed).

Parameters:
Name Type Description
key String

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

url String

Remote destination.

fileFormValue String

Name of parameter server expects file data to be associated with. Must not be a key in formValues.

fileArray Array:.<String:>

List of local paths of files to upload.

formValues Object

Index of keys and values to send with file data. Must not contain a key equal to fileFormValue.

Source:
See:
Example
OrionUpload.uploadFile('000000-000000-00000-0000', 'http://www.example.com/upload_file.php', 'file', ['/Users/dgooden/foo.tar.gz'], {'foo': 'bar'});

<static> uploadFileToAPI(key, url, fileFormValue, fileArray, formValues)

The usage is exactly the same as OrionUpload.uploadFile. It just will call the API instead of a normal server. Pass '/v5/some/api/call' as the url.

Parameters:
Name Type Description
key String

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

url String

Remote destination.

fileFormValue String

Name of parameter server expects file data to be associated with. Must not be a key in formValues.

fileArray Array:.<String:>

List of local paths of files to upload.

formValues Object

Index of keys and values to send with file data. Must not contain a key equal to fileFormValue.

Source:
See:
Example
OrionUpload.uploadFile('000000-000000-00000-0000', '/v5/some/api/call', 'file', ['/Users/dgooden/foo.tar.gz'], {'foo': 'bar'});