Hello there đź‘‹

Thanks for stopping by! We use cookies to help us understand how you interact with our website.

By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.

Where does st.file_uploader store uploaded files and when do they get deleted?

When you upload a file using st.file_uploader, the data are copied to the Streamlit backend via the browser, and contained in a BytesIO buffer in Python memory (i.e. RAM, not disk). The data will persist in RAM until the Streamlit app re-runs from top-to-bottom, which is on each widget interaction. If you need to save the data that was uploaded between runs, then you can cache it so that Streamlit persists it across re-runs.

As files are stored in memory, they get deleted immediately as soon as they’re not needed anymore.

This means Streamlit removes a file from memory when:

  • The user uploads another file, replacing the original one
  • The user clears the file uploader
  • The user closes the browser tab where they uploaded the file

Related forum posts:

forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.