Advanced fast files upload
When API functions is not enough for you to get full control over the uploading process, use the UploaderFlow class. Since file uploading in a browser is based on using callbacks, this class offers event-based API to control the uploading flow. After inheriting from this class, you should implement its abstract methods, and define event methods you need (they are empty by default), then create an instance of the class and invoke the run() method.
All API functions have this class inside for all internal works with uploading, and are basically wrappings for the
UploaderFlow class for most frequent uses.
Note. Quick uploading does not imply displaying the File Uploader dialog. If you need to fine tune settings and display the dialog, please use the UploaderUiFlow class instead.
UploaderFlow class operation flowchart
: stringUploading script URL. Should be set once when getUrlUploader is called upon start.
: FileThe list of files to upload. The list if filled in when the getFilesToUpload function is called in the beginning of the flow, or after the browser file selection dialog is shown and before onAfterSelected.
: stringThe unique ID of the transaction. Generated on the server-side and is filled in during uploading initialization (before calling onAfterInit).
The list of data about files uploaded to the server but nit yet committed (that is, files are still in the temporary directory). Filled in after the uploading stage before calling `onAfterUpload`.
: ServerFileThe list of files uploaded to the server and committed. This property is filled after the last stage of uploading, commit, successfully finishes, directly beforeonAfterCommit.
: stringA localized error message. Filled in in case of an error on any stage, before invoking the corresponding method that handles errors(for instance, onFailAfterUpload.
Called upon start, before any other code is executed.
Called after the user selects files in the browser file selection dialog. If you skip file selection by returning `null` using the getFilesToUpload
method, then this method is also not invoked.
Available properties: files
Called after uploading initialization.
Available properties are those filled in on the previous step and uploadId
Called after uploading all files, but before commit of transaction. All uploaded files at this stage are located in the temporary directory on the server.
Available properties are those filled in on the previous step and serverFilesUploaded
Called after all uploading stages are done.
Available properties are those filled in on the previous step and serverFilesCommited(#serverFilesCommited).
Called upon an error occurred during uploading initialization. The error message is available in the errorMessage
Called upon an error occurred during uploading of files. The error message is available in the errorMessage
Called upon an error occurred during transaction commit. The error message is available in the errorMessage
Called on any error after a specialized error handling method is called (see above). The error message is available in the errorMessage
Called when `UploaderFlow` finishes with whatever result. This is the last event available in this particular flow.
Returns `true` if multiple file selection is permitted in the browser file selection dialog. The default value is `true`. Override the method in the class descendant if you want to change this behaviour.
Returns accepted MIME types filter. May return `image/*` (for example) if overridden. By default returns `null` (all files are allowed). Note that filtering may work in its own way in different browsers and operating systems depending on the standards implemented in a browser.
abstract getUrlUploader(): string
Returns the upload script URL that handles all requests.
abstract getFilesToUpload(): File
Returns the list of files to upload. By default returns `null`, which results in opening of the browser files selection dialog. If an array of `File` object from File API
is returned, the file selection step is skipped, and `UploaderFlow` goes to transaction initialization.
abstract getPresetData(): PresetData
Returns the only preset with uploading settings.
abstract getUserOptionsData(): UserOptionsData
Returns user options used to commit the transaction (resizing of images, renaming files etc. takes place here).
Puts the flow to operation. Do not override this method. If you need to change the behaviour on early stages, use the onStart