onBeforeAdd not preventing file upload

On version 5.1 of the filemanager and initializing the filemanager with:

on: {
‘onBeforeAdd’: function (id, obj, index) {
return false;
}
}

This is not preventing files from uploading to the server. In version 4 it did. The following javascript error is also thrown:

Uncaught TypeError: Cannot read property ‘$parent’ of undefined
at webix.DataStore.changeId (webix_debug.js:13530)
at o. (filemanager.js?v=bGpZAfwPnOEE1wLOAxlMPpQN12H4phUfc1KlMmkz8Tk:9)
at o.callEvent (webix_debug.js:546)
at o.js (webix_debug.js:36081)
at o.is (webix_debug.js:35907)
at o. (webix_debug.js:35882)
at XMLHttpRequest. (webix_debug.js:243)

This is due to the server upload action being called and returning an item which tries to replace the non-added one.

Is this a bug in the system or am I doing something wrong?

Hi,

Could you please specify the exact version where this implementation works? According to my tests, the main pattern of file uploading/adding has not changed from version 3.4

As in every other data component, onBeforeAdd fires in the moment before an item will be added to the FileManager’s DataStore, i.e. this method is related to the client-side data processing.

To prevent the entire file processing, please use onBeforeFileAdd event of uploader:

$$("fm").getUploader().attachEvent("onBeforeFileAdd", function(details){
	return false;
});