Skip to content

zzarcon/flat-files

Repository files navigation

Get a flatten array of dropped files using FileSystem api

Demo

https://zzarcon.github.io/flat-files

Usage

import flatFiles from 'flat-files';

flatFiles(document.querySelector('#dropzone'), (files: FileSystemEntry[]) => {
  files.forEach(file => {
    console.log(
      file.name,
      file.fullPath,
      file.getMetadata()
    );
  })
});

Use case

Imagine you have drag & drop support in your app, thats great. Now imagine the use drops a folder containing a folder containing a folder, containing a folder... you get the idea.

All that I want is to have a nice way to get all those files and do something with them (upload them, show a preview, etc). Thats what flat-files gives to you, it deals with the FileSystem and gives a flatten array of FileSystemEntry

TODO

  • Release script
  • Browser support
  • Error callback