Page tree
Skip to end of metadata
Go to start of metadata

RELEASE 2.2.0 OR ABOVE

This event occurs after a file is uploaded.

Adding Event

Using API

var editorId = 'synapEditor';
var editorConfig = {};
var html = '';
var editor = new SynapEditor(editorId, editorConfig, html);


editor.setEventListener('afterUploadFile', function (e) {
});

Function

var editorId = 'synapEditor';
var editorConfig = {};
var html = '';

function SynapEditorAfterUploadFile(e) {
}

new SynapEditor(editorId, editorConfig, html);

When the Editor is initialized

var editorId = 'synapEditor';
var editorConfig = {};
var html = '';
var eventListeners = {
    afterUploadFile: function (e) {
    }
};

new SynapEditor(editorId, editorConfig, html, eventListeners);

Object Delivered through Functions

In the form of parameter e delivered through functions

e
// release 2.2.0
{
	editor: SynapEditor,
	eventType:  'afterUploadFile',
	cancelable: false,
	returnValue: null,
	path: '/upload/path/filename.zip' // The upload path.
}
// release 2.2.1 or above
{
	editor: SynapEditor,
	eventType:  'afterUploadFile',
	cancelable: false,
	returnValue: null,
	fileType: 'file', // [2.2.1] File type
	path: '/upload/path/filename.zip'
}
// release 2.10.0 or above
{
	editor: SynapEditor,
	eventType:  'afterUploadFile',
	cancelable: false,
	returnValue: null,
	fileType: 'file',
	path: '/upload/path/filename.zip',
    responseData: {},   // [2.10.0] complete response data
}
// release 2.15.0 or above
{
	editor: SynapEditor,
	eventType:  'afterUploadFile',
	cancelable: false,
	returnValue: null,
	fileType: 'file',
	path: '/upload/path/filename.zip',
    responseData: {},
    error: undefined    // [2.15.0] Error information when upload fails
}

File upload failed

RELEASE 2.15.0 OR ABOVE

Starting with the 2.15.0 release, the afterUploadFile event is also raised when an upload fails.

An Error object is passed to the error property of the object that is passed to the afterUploadFile event when upload fails.

Example of notification window when upload fails

editor.setEventListener('afterUploadFile', function (e) {
    if (e.error && e.error.status === 500) {
        e.editor.execCommand('showDialog', 'alert', 'File upload failed.');
    }
});
  • No labels