-
Notifications
You must be signed in to change notification settings - Fork 66
Add directory picker for wasmJs #548
Description
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.