I’m trying to enable simple file download from the Filemanager on double click.
The existing examples show a call through a PHP script but, I want to delivery directly from the CDN using HTTP GET.
By attaching to onItemDblClick from a TreeView, we can do the necessary work from a standalone TreeView example but, how do I enable the same simple HTTP GET based functionality for the Filemanager widget proper?
While I’m asking about download, what about upload?
Must the Webix client call a backend PHP script? Or can it issue an HTTP POST directly to a named folder?
If so, can the response message be synthesized from within the application using an override? Or must the service(CDN) return the expected JSON formatted response?
In this case, requiring the backend to conform to the webix client is not a desirable option.
Ok, after a little more research I’ve learned 2 things.
First, I can override filemanager.delete, as I did with the download function, and get everything I need.
Second, for most browsers, uploading files requires the use of the FormData interface and that will break my plan to post files directly to the CDN storage interface; an application server is required to parse and remove the “WebKitFormBoundary” headers surrounding the data of interest.
Happy to hear from anyone else who managed to work around this, but it looks like I’ve reached the end of this journey.
What concerns file downloading, there’s no possibility to customize it via proxy, unfortunately.
So, you can either modify the download method of a File Manager widget and force the webix.send to issue a GET request
webix.protoUI({
name:"myFileManager"
download:function(id){
var url = this.config.handlers.download;
if (url)
//adding the third parameter with method name
webix.send(url, { action:"download", source: id }, "GET");
}
}, webix.ui.filemanager);
webix.ui({ view:"myfilemanager", ...})
Or, catch the onBeforeRun event and call your download logic there
$$("files").attachEvent("onBeforeRun",function(id){
//your logic
//returning false is vital since it cancels the default processing.
return false;
})
From my side, theonBeforeRun event is more flexible. It does not affect other File Manager instances while propotype modifications do.