content icon indicating copy to clipboard operation
content copied to clipboard

File System Access API is incomplete

Open odebroqueville opened this issue 3 years ago • 1 comments

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle

What specific section or headline is this issue about?

FileSystemDirectoryHandle

What information was incorrect, unhelpful, or incomplete?

The File System Access API doesn't address the question of how to manage package bundles (e.g. .textbundle files) or compressed archives (e.g. .zip files).

The above types of files have a kind of 'file' when they should really be identified as having a kind of 'Directory'.

You cannot use window.showDirectoryPicker() to select a package bundle or zip archive.

The window.showOpenFilePicker() allows us to select the above types of files, but won't allow us to work with their contents.

What did you expect to see?

Package bundles or compressed archives should really be identified as having a kind of 'Directory' and be accessible using the window.showDirectoryPicker() method.

We should be able to identify and iterate through the contents of such packages.

Do you have any supporting links, references, or citations?

https://playcode.io/1000385

Do you have anything more you want to share?

No response

MDN metadata

Page report details
  • Folder: en-us/web/api/filesystemhandle
  • MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle
  • GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/filesystemhandle/index.md
  • Last commit: https://github.com/mdn/content/commit/5f80944f03f785c729c12ac143cf88a1c12e72cd
  • Document last modified: 2022-10-10T08:12:11.000Z

odebroqueville avatar Nov 02 '22 10:11 odebroqueville

Hi @odebroqueville thanks for opening the issue.

.textbundle files or compressed archives (e.g. .zip files)... have a kind of 'file' when they should really be identified as having a kind of 'Directory'.

Compressed archives (e.g. .zip files) are a file type and cannot be selected by window.showDirectoryPicker(). This is the same with .textpack files. I haven't worked too much with .textbundles, but they appear to be directories that can be handled by window.showDirectoryPicker().

We have a reference for window.showDirectoryPicker(), it looks like we can link to window.showOpenFilePicker() from this page when looking to work with compressed archives.

demo:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
  </head>

  <body>
    <button id="button">Choose a directory</button>
  </body>
  <script>
    const chooseButton = document.querySelector('#button');

    chooseButton.onclick = async (e) => {
      const dir = await window.showDirectoryPicker();
    };
  </script>
</html>

output:

image

bsmth avatar Nov 04 '22 19:11 bsmth

This looks like a feature request for browsers to natively handle zip files. The answer is they currently cannot and I don't think they ever will. If you want to manipulate zip files as directories, you can use a library like jszip.

Josh-Cena avatar Jun 18 '23 14:06 Josh-Cena