Class: UWA.Services.Upload

UWA/Services/Upload. UWA.Services.Upload

new UWA.Services.Upload(options)

UWA.Services.Upload constructor.

Example
var myService = new UWA.Services.Upload({
    onUploadSuccess: Bookmarks.onUploadSuccess,
    onUploadFailed: Bookmarks.onUploadFailed,
    onUpload: Bookmarks.onUpload,
    formElement: uploadForm,
    frameIdPrefix: 'Bookmarks',
    urls: {
        statusScript: 'http://www.netvibes.com/api/my/bookmarks/import/status',
        uploadScript: 'http://www.netvibes.com/api/my/bookmarks/import'
     }
});
Parameters
Name Type Description
options Object

Options hash

Properties
Name Type Argument Default Description
isUploadSuccess Function <optional>

Callback used to validate upload success state

isUploadFailed Function <optional>

Callback used to validate upload failed state

formElement Element <optional>

Form Dom Element

onUpload Function <optional>

Callback fired when upload start

onUploadSuccess Function <optional>

Callback fired when upload finish with success

onUploadFailed Function <optional>

Callback fired when upload fails

frameIdPrefix String <optional>
''

Prefix of the frame id

timeout Number <optional>
10000

Timeout limit (in micro seconds)

polling Number <optional>
1000

Polling interval (in micro seconds)

urls Object <optional>

Endpoints ({statusScript: '', uploadScript: ''})

Index

Methods

buildIframe() → {Number}

Inject Upload iframe to current HTML page.

Returns

Id of the recently created frame

Type
Number

buildFormRequirements(frameId)

Add form requirements (multipart option, hidden fields...) usefull for Upload component to do its job.

Parameters
Name Type Description
frameId Number

Id of the frame

setTimer(frameId)

Fire this.checkStatus each this.options.poll microseconds unless this.options.timeout is reached

Parameters
Name Type Description
frameId Number

Id of the frame

checkStatus(frameId)

Ask to status endpoint the upload status.

Parameters
Name Type Description
frameId Number

Id of the frame