Skip to content

Add directory picker for wasmJs #548

@timo-drick

Description

@timo-drick

I think it is technically possible to support the directory picker also in wasmJs target.
In theory there is this File System Access API. But it is only supported on chrome based browsers.
But there is another option using the same method which is already implemented in wasmJs openFilePicker implementation.
It is supported on all major browsers. And in my project it works.
So it is just an attribute in the input html element called webkitdirectory:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory

The thing is that the dialog will than return a list of File elements. But the File does also have a additional attribute: webkitRelativePath
https://developer.mozilla.org/en-US/docs/Web/API/File/webkitRelativePath
I do have implemented a prototype for my project but for me it was fine to just have a file list. Of course for the Filekit project maybe PlatformFile directory entries needed to be created. Not sure about this. So would like to discuss.
Prototype implementation: https://github.com/timo-drick/WTF-Flight-Log/blob/main/libs/file_handling/src/webMain/kotlin/de/drick/filehandling/FileInputForm.kt

I really appreciate this project. Thank you very much for the great work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestFeature asked by the community

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions