vscode.dev uses the File System Access API, which allows web applications to directly read and modify the filesystem.
Rather than using a <input type="file" />
, it calls window.showOpenFilePicker()
to get a FileSystemFileHandle
, which can then, in turn, be read and converted into a FileSystemWritableFileStream
to which the browser can write and save files. Similarly, the API can handle directories and browse the file hierarchy.
Of course, this is a simplification, as I could not possibly go through every detail of the API in this answer. The MDN article has a lot of examples and thorough documentation that you will want to read through. For testing, it should be noted that the API is only available on sites served through HTTPS, so you're going to need to set up SSL for your localhost
. Also, the API is not available in all browsers, so be sure to check the compatibility table.