Converting an absolute path to a FileEntry


#1

In my application users can select a directory using the dialog.showOpenDialog. Now I want to convert this absolute path to a FileEntry object; http://www.html5rocks.com/en/tutorials/file/filesystem/

Normally window.webkitResolveLocalFileSystemUR should accept an absolute path and convert it into a FileEntry object; however in Electron it will result to the following error

"A URI supplied to the API was malformed, or the resulting Data URL has exceeded the URL length limitations for Data URLs."

Example:

window.webkitResolveLocalFileSystemURL('file:///', function(directoryEntry) {
  console.log('success', directoryEntry);
},
function (e) {
  console.log(e);
});

I suspect there must be a permission that allow mainWindow to have access to the loca directory perhaps. Any idea?


#2

This is the reason that Electron includes Node, so that you don’t have to deal with experimental APIs to access the file system. Use the Node fs library and everything gets much easier :grinning:


#3

So in my case I use a big library that is optimized to work with the FileSytem API. If somehow I can convert the initial absolute path to a FileEntry (fs.root), everything else works as expected. Converting the whole thing to Node’s fs is going to be a big headache.