Resolve symbolic links in File System Web API

19 Views Asked by At

I have a simple web-page which accepts local files both via file picker dialog and drag'n'drop. Here is the event handlers:

async function drop(ev)
{
  ev.preventDefault();
  if(ev.dataTransfer.files.length)
  {
    entry = await ev.dataTransfer.items[0].getAsFileSystemHandle(); // also tried .webkitGetAsEntry() .getAsFile()
    process(entry);
  }
}

async function openFile()
{
  [fileHandle] = await window.showOpenFilePicker();
  process(fileHandle);
}

The further processing of data goes in the function process but is not important here. File System API is enabled in the browser settings, there are no errors.

The problem happens when I pass not an actual file but a symbolic link to it into the browser.

The file picker method successfully resolves the link to the actual target file and the page reads correct data, but when drag'n'drop is involved, the DataTransfer object does always contain the link, not the actual file with data.

Is there a way to fix this and make File System API fully functional during drag'n'drop operations?

I'm using Windows 11, symlinks are standard ones - created from command line (mklink link target) or programmatically (CreateSymbolicLink). I did not test, if the same problem occurs under Linux.

0

There are 0 best solutions below