I have a question regarding file_uploader - it allows for uploads of directories with accept_multiple_files="directory". However, this uploads all directory contents, which can be only filtered by the file type.
I’m wondering - if it’s possible somehow to utilize regex, to filter-out unnecessary files before uploading the rest of the directory?
I know a custom component can be created to do this but I’m wondering if there’s a simpler and easier to maintain option.
Welcome to the Streamlit community and thanks for your thoughtful question! Currently, Streamlit’s st.file_uploader supports directory uploads using accept_multiple_files=“directory”, and you can filter files by extension or MIME type via the type parameter. However, there is no built-in support for regex-based filtering of files before upload—only file type filtering is available out of the box. Regex or more advanced filtering would require a custom component or post-upload processing in Python code after the files are received by the app.
If you want to filter files by more complex patterns (like regex), you’d need to either (1) let users upload all files and then filter them in your app logic, or (2) build a custom component for client-side filtering. There’s no simpler, built-in way to do regex filtering before upload in the current Streamlit API. See the official docs and related PRs for details: st.file_uploader docs, directory upload PR.