GoogleChromeLabs / browser-fs-access

File System Access API with legacy fallback in the browser
https://googlechromelabs.github.io/browser-fs-access/demo/
Apache License 2.0
1.37k stars 82 forks source link

Network folders #149

Closed tomasgrunt closed 8 months ago

tomasgrunt commented 8 months ago

Hi,

this is not an issue but I would like to know, if this browser-fs-access can be used for:

Thank you

tomayac commented 8 months ago

Just did a quick experiment. You need to pass a FileSystemHandle as the startIn option, and it does work if this points to a network location. I have split it up in two buttons so you can see the effect more easily.

import { fileOpen } from 'browser-fs-access';

let handle;

document.querySelector('.button1').addEventListener('click', async () => {
  try {
    const file = await fileOpen();
    handle = file.handle;
  } catch (err) {
    console.log(err)
  }
});

document.querySelector('.button2').addEventListener('click', async () => {
  try {
    const file = await fileOpen({    
      startIn: handle
    });  
  } catch (err) {
    console.log(err)
  }
});
  1. Open a file from a network drive to get a handle with the first button: Screenshot 2023-11-29 at 11 26 20
  2. The second button then starts the dialog in the network drive: Screenshot 2023-11-29 at 11 26 33