Default directory for file_uploader

Hello All,

I am using a file_uploader in my app and I want to set a default directory for it. I would like to know if there is a way to do it ?

Hi @Harish_Kodarapu -

The file_uploader never writes to disk, as its more performant to not write to disk. Meaning, the flow is that the browser takes in a stream of bytes, which is written on the Python side to a BytesIO buffer.

If you have the desire to write the data to a physical file, you can do so via Python using the standard Python file writing capabilities.

Best,
Randy

Hi @randyzwitch,

Thank you for the reply. I believe my question was understood in a wrong way. I would like to use a file_uploader. When I click on browse files, I want my file_uploader to open a specific directory instead of last opened.

I did not mean writing to a specific directory. Infact, I wanted to know how to read only from a specific directory.

Thanks and Regards,
Harish.

Hi @Harish_Kodarapu -

I believe this would be a function of the browser settings, not something that could be controlled from Streamlit. In the abstract, the developer of the Streamlit app (or any web page) shouldn’t know anything about the structure of the users filesystem. Certainly not the ability to write to arbitrary directories.

Best,
Randy