API Uploader

Hi,

How to use webix uploader for api like this http://databoom.space/docs.html#!/restapi/part6 ?
I tried to use your example here http://webix.com/snippet/3d43a5ce
but still not work. It should be a simple one, but I don’t know how to make it in webix.

Thank you…

Hi,

first of all, you should use autosend:true (or just not use autosend:false) to start uploading after selecting an image from the file system.

Secondly, you should check what is returned by the POST request as exactly this response comes into onFileUpload event.

And here we encounter the problem that Databoom actually returns no response! You can see it even when trying to upload the file in the admin area in the Files tab.

Such a situation (no response) is interpreted as upload error by Webix Uploader and it issues the onFileUploadError event.

But there can be a workaround. You can catch the onDataUpdate event of the uploader file storage and take file info from handler parameters:

view:"uploader",
"files->onDataUpdate":function(id, item){
        //item - context, file, id, name, size, sizetext, status, type 
        var id = item.context.rowid;
        var row = $$("people").getItem(id);
        row.photo = item.name;
        $$("people").updateItem(id, row);
}

http://webix.com/snippet/6a589a6a

Note that in the background onFileUploadError is still triggered while onFileUpload never fires. But we assume that Databoom always works neatly :slight_smile:

Wow! That was an awesome answer and explanation. Thank you very much for your help Helga!