javascriptjqueryjquery-uielfinder

How can I log removed file name in elFinder with Client-event API?


I am trying to create Ajax logging feature for elFinder so I added event handlers:

'elfinder': {
    handlers : {
        add : function(event, elfinderInstance) {
            console.log(event.data);
            //console.log(event.data.selected); // selected files hashes list
        },
        remove : function(event, elfinderInstance) {
            console.log(event.data);
            //console.log(event.data.selected); // selected files hashes list
        }
    }
}

Client-event-API

From add event I get all data I need, part of the nested object data for example:

hash: "l1_UypQLTJfOC9TY3JlZW5zaG90IDIwMjEtMDMtMTEgYXQgMTUuMTguNDcucG5n"
isowner: false
mime: "image/png"
name: "Screenshot 2021-03-11 at 15.18.47.png"
phash: "l1_UypQLTJfOA"
read: 1
size: "60591"
tmb: 1
ts: 1616364008
url: "/php/../files/S%2AP-2_8/Screenshot%202021-03-11%20at%2015.18.47.png"
write: 1

Most importantly url and name of the added file.

But on remove I get only:

0: "l1_UypQLTJfOC9TY3JlZW5zaG90IDIwMjEtMDMtMTEgYXQgMTUuMTguNDcucG5n"
length: 1

How can I log removed file name in eFinder?


Solution

  • Because the path encoding method can be changed with the volume driver, the client side does not implement a function to decode it.

    However, if it is the default encoding method, it can be decoded as follows.

    var hash = 'l1_RG93bmxvYWRz';
    var encPath = hash.substr(hash.indexOf('_')+1);
    var path = '/'+atob(encPath.replace(/\-/g, '+').replace(/_/g, '/').replace(/\./g, '='));
    

    Reference: https://github.com/Studio-42/elFinder/issues/2011