useFilePicker
useFilePicker copied to clipboard
Read folder
Hi there, I really enjoy using your file picker. Would it be possible to add the ability to select folders and get their respective content? Thank you.
Hi @MohrJonas, happy to hear that you like our package!
Would it be possible to add the ability to select folders and get their respective content?
Yes, it's on our roadmap. We already have an idea how to implement this, as we did research around browser APIs for directory pickers some time ago. Unfortunately, I don't have any estimates regarding the release date of such a feature. Right now, we're focusing on delivering v2.0.0 of use-file-picker that significantly improves DX and fixes some bugs. But right after that, we can dive into the select folders feature. I'll make sure to mention this issue in the PR that introduces the select folders feature, so you get a notification when it happens.
Amazing to hear. Thank you very much
Hi @MohrJonas, happy to hear that you like our package!
Would it be possible to add the ability to select folders and get their respective content?
Yes, it's on our roadmap. We already have an idea how to implement this, as we did research around browser APIs for directory pickers some time ago. Unfortunately, I don't have any estimates regarding the release date of such a feature. Right now, we're focusing on delivering v2.0.0 of use-file-picker that significantly improves DX and fixes some bugs. But right after that, we can dive into the select folders feature. I'll make sure to mention this issue in the PR that introduces the select folders feature, so you get a notification when it happens.
Can you share some hints about how you thought to achieve this functionality? From playing around with the options, it doesn't seem like a built-in browser picker can allow selection of both files and folders. Unless we are only talking about folder picking. ref https://stackoverflow.com/a/16774922/1236401 , which is old, but seems no updates since (?)
@ReallyLiri
You're right, there's no built-in browser picker that allows for selection of both files and folders, so we're only talking about directory picking.
To shed some light on the actual implementation, we were thinking about creating a new hook exported from our package called useDirectoryPicker
. It would be based on a part of this library browser-fs-access which is a ponyfill for File System API. The most popular browsers have support for directory picking with fs api since 2021 (Safari was last to implement it). It also falls back to the legacy webkitdirectory
property on a plain input element that you've linked, if the user's browser does not support the new fs api.