javascriptelfinder

elFinder How to get protocol name


I open elFinder in popup window and i got files in this callback:

getFileCallback: function (file) {
 var w = window.opener || window.parent || window;
     w.postMessage && w.postMessage(JSON.stringify(file), '*');
     $('#elfinder').remove();          
},

Is it possible to get source protocol each of file: dropbox, gdrive, ftp?


Solution

  • If you are using official PHP volume drivers.

    getFileCallback: function (file) {
     var w = window.opener || window.parent || window;
         var drivers = {
            bd: 'Box',
            db: 'Dropbox',
            f:  'FTP',
            gd: 'GoogleDrive',
            l:  'LocalFileSystem',
            od: 'OneDrive',
         }, m;
         if (m = file.hash.match(/^(bd|db|f|gd|l|od)/)) {
            file.driver = drivers[m[1]];
         }
         w.postMessage && w.postMessage(JSON.stringify(file), '*');
         $('#elfinder').remove();          
    },
    

    Please check file.driver.