Skip to content

Unify File Import Behavior Across Input, Drop Events, and File System APIs #1

@tabcat

Description

@tabcat

I'm considering adding some utilities that would help unify behavior between all the separate import methods.
The idea is to make importing the same set of files/dirs result in an identical cid independent of which import method was used.
This is important as it will provide users with a solution to reliably import from most browser platforms.

I also want to make it easy to wrap the imported content in a directory on the condition of there being multiple pieces of content without a shared root directory.

The separate import methods:

Behaviors:

Method / Element Result Type Items Support Level Mobile Friendly
<input type="file"> FileList 1 file ✅ Standard ✅ Yes
<input type="file" multiple> FileList 1 + files ✅ Standard ✅ Yes
<input type="file" webkitdirectory> FileList 0 + files (in dirs) ☑️ Non-standard ✅ Yes
Drop Event FileSystemEntry[] / FileSystemHandle[] 1 + files / dirs ☑️ Partially standard ❌ No
showOpenFilePicker() FileSystemFileHandle[] 1 + files 🟡 Draft standard ✅ Yes
showDirectoryPicker() FileSystemDirectoryHandle 1 dir 🟡 Draft standard ✅ Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions