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.38k stars 84 forks source link

List of accepted file types #60

Closed PeterNjeim closed 3 years ago

PeterNjeim commented 3 years ago

Is it possible to allow multiple file types, separated in a list, with separate descriptions for each?

Of course, I can allow as many file types as I want, however I would like to follow what desktop programs do, and separate them out like this: image Not a deal breaker obviously, just wondering if it's even possible on the web

tomayac commented 3 years ago

This is certainly possible with the File System Access API:

await showOpenFilePicker({
  types: [
    {
      description: 'Text Files',
      accept: {
        'text/plain': ['.txt', '.text'],
        'text/html': ['.html', '.htm']
      }
    },
    {
      description: 'Images',
      accept: {
        'image/*': ['.png', '.gif', '.jpeg', '.jpg']
      }
    }
  ],
});

I'm looking to add a way to make this happen in browser-fs-access.

tomayac commented 3 years ago

This is now supported as of v0.20.0, which will go out in a moment.

Screen Shot 2021-08-06 at 17 37 37