API Docs for: 0.0.1
Show:

Uploader Class

Module: uploader

Provides core Upload-functionality. Also definesHTMLInputElement.prototype.sendFiles.

The Uploader is a Class, which can be instantiated with a config-object: {url: {String}, the default url to send to params: {Object}, the default params that will be send with the request options: {Object}, the xhr-options (see http://itsa.io/api/classes/IO.html#method_sendBlob) maxFileSize: {Number}, the maximum filesize for every single file to be accepted. Note that the server needs to controll this, however, when set, the uploader is enabled to show a proper warning while rejecting the io-promise totalFileSize: {Number} the maximum filesize for all files (cummulated) to be accepted. Note that the server needs to controll this, however, when set, the uploader is enabled to show a proper warning while rejecting the io-promise }

Copyright (c) 2014 ITSA - https://github.com/itsa New BSD License - http://choosealicense.com/licenses/bsd-3-clause/

Methods

_defFnSelectFiles

(
  • e
)
private

Defined in src/uploader/uploader.js:329

Available since 0.0.1

Default function for the uploader:selectfiles-event

Parameters:

  • e Object

    eventobject

    • [multiple] Boolean optional

      whether to support multiple selected files

_defFnSend

(
  • e
)
private

Defined in src/uploader/uploader.js:349

Available since 0.0.1

Default function for the uploader:send-event

Parameters:

  • e Object

    eventobject

    • [url] String optional

      overrules the default url

    • [params] Object optional

      overrules the default params

    • [options] Object optional

      overrules the default options

_storeLastSent

() private chainable

Defined in src/uploader/uploader.js:396

Available since 0.0.1

Stores the files that are sent into an internal hash, which can be read by getLastSent().

clearDefaults

() chainable

Defined in src/uploader/uploader.js:105

Available since 0.0.1

Clears the default transition-values that are being used for the values of url, paramsandoptions`.

count

() Number

Defined in src/uploader/uploader.js:122

Available since 0.0.1

Returns the number of files that are currently selected.

Returns:

Number:

Number of files currently selected

destroy

()

Defined in src/uploader/uploader.js:133

Available since 0.0.1

Destroys the fileselector: removes all eventlisteners and removes its protected input-domNode.

getDomNode

() DOMNode

Defined in src/uploader/uploader.js:143

Available since 0.0.1

Returns the protected input-domNode whichis being used by this uploader-instance.

Returns:

DOMNode:

protected input-domNode

getFiles

() Array-like

Defined in src/uploader/uploader.js:154

Available since 0.0.1

Returns the currently selected files. This is an Array-like object, not a true Array.

Returns:

Array-like:

protected input-domNode

getLargestFileSize

() Number

Defined in src/uploader/uploader.js:165

Available since 0.0.1

Returns the size of the largest file that is currently selected.

Returns:

Number:

The size of the largest file in bytes

getLastSent

() Array

Defined in src/uploader/uploader.js:185

Available since 0.0.1

Returns the last send-files. This is handy to know, because after transmission, getFiles() will return empty. This is an true Array with objects of this structure: {name: xxx, size: xxx}

Returns:

Array:

The last sent files

getTotalFileSize

() Number

Defined in src/uploader/uploader.js:198

Available since 0.0.1

Returns the total size of all files that are currently selected.

Returns:

Number:

The size of all files in bytes

hasFiles

() Number

Defined in src/uploader/uploader.js:218

Available since 0.0.1

Whether there are currently files selected.

Returns:

Number:

Number of selected files

selectFile

(
  • [payload]
)
chainable

Defined in src/uploader/uploader.js:229

Available since 0.0.1

Pops-up the browser's fileselect, by emitting the 'uploader:selectfiles'-event. The fileselector allows you to send only 1 file at a time. If payload.autoSend is set, the files will automaticly be send after selection. You also can set other properties at the payload --> these will be available at the listeners.

Parameters:

selectFiles

(
  • [payload]
)
chainable

Defined in src/uploader/uploader.js:255

Available since 0.0.1

Pops-up the browser's fileselect, by emitting the 'uploader:selectfiles'-event. The fileselector allows you to send multiple files at a time. If payload.autoSend is set, the files will automaticly be send after selection. You also can set other properties at the payload --> these will be available at the listeners.

Parameters:

send

(
  • [payload]
)
chainable

Defined in src/uploader/uploader.js:275

Available since 0.0.1

Send the selected files, by emitting the 'uploader:send'-event. If payload.url, payload.url or payload.url is set, then these will overrule the default values (the way they were set at initiation, or by using setDefaults). You also can set other properties at the payload --> these will be available at the listeners.

Parameters:

setDefaults

(
  • [url]
  • [params]
  • [options]
  • [maxFileSize]
  • [totalFileSize]
)
chainable

Defined in src/uploader/uploader.js:302

Available since 0.0.1

Sets the default transition-values that are being used for the values of url, paramsandoptions`. These values might have been set during initialization, if so, any values passed will be overrule the previous.

Parameters:

  • [url] String optional

    the default url to send to

  • [params] Object optional

    the default params that will be send with the request

  • [options] Object optional
  • [maxFileSize] Number optional

    the maximum filesize for every single file to be accepted. Note that the server needs to controll this, however, when set, the uploader is enabled to show a proper warning while rejecting the io-promise

  • [totalFileSize] Number optional

    the maximum filesize for all files (cummulated) to be accepted. Note that the server needs to controll this, however, when set, the uploader is enabled to show a proper warning while rejecting the io-promise

Properties

_inputNode

DOMNode private

Defined in src/uploader/uploader.js:56

Available since 0.0.1

Hidden input-node of the type file that is being used to transfer the files.

_lastfiles

Array private

Defined in src/uploader/uploader.js:65

Available since 0.0.1

Private Array with objects of this structure: {name: xxx, size: xxx}. Holds the file-info of all files that have been send by the last transfer. Can be used by the method: getLastSent()

Default: []

Events

uploader:fileschanged

Defined in src/uploader/uploader.js:92

Available since 0.1

Fired internally whenever the selected files are changed. Its defaultFn will start sending the files (if the selection is triggered with autoSend=true)

uploader:selectfiles

Defined in src/uploader/uploader.js:244

Available since 0.1

Fired to start selecting the files. Its defaultFn will pop-up the file-selector.

uploader:send

Defined in src/uploader/uploader.js:291

Available since 0.1

Fired to start uploading through io. Its defaultFn will invoke sendFiles of the input-node.