Can I prepopulate with a file path to the st.file_uploader?


Set a default file path for the file_uploader before it opens, so that the file is selected by the st.file_uploader function caller.

Steps to reproduce

Now a days with NPL as the user interface, we don’t like to many popping-up widgets to interact with the user.
For example: in an input file field, user just types “Please processing the file_xyz.txt and give me the resulted file back!”. So the app should work out the file_xyz.txt from the sentence and load it to the streamlit app on the server to process it.

I don’t see how a file on the client’s machine can be uploaded without using the st.file_uploader widget. Even using the widget, there is no way I can pre-select the file path already being worked out from the user’s input.

It would great if the st.file_uploader could be updated to handle such cases, ideally it should be called silently, i.e. no need to popping up.

Hey @T_Ye,

Thanks for sharing this question. This isn’t supported out of the box – there isn’t a way to provide st.file_uploader with a file path without allowing the user to select the file.

The problem you would run into even if this were supported is that users don’t necessarily know the path to their file off the top of their head. I think you’d end up with users having to search for the file and figure out the path, and at that point, it would be faster/less of a headache for them to select the file. Just my take though.

Feel free to also share this as an enhancement request if you’d like our product team to consider it

Thank you very much for the reply!

The point here is for natural language processing, file paths are often already in the text and the application should process those files silently. Popping up a lot of widgets or clicking a number of buttons for user interactions are too “old fashion” way of thinking :slightly_smiling_face:

Hope you your development team could consider such enhancement requests.

Best regards

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.