Download Multiple Files with st.download_button()

Hello everybody!
In the code below, I’m trying to get the user to download either file1, file2, or both.
But when one of the buttons is used, the app reloads and there is no possibility to download the other file.

Is there a workaroud for this requirement?

Thank you so much for your help!


# Download file 1
with open(file1_path, "rb") as file1:   
    st.download_button(
        label="Download File 1",
        file_name=f"File1-{date_and_time}.json",
        data=file1,
        mime="application/json",
    )

# Download file 2
with open(file2_path, "rb") as file2:   
    st.download_button(
        label="Download File 2",
        file_name=f"File2-{date_and_time}.json",
        data=file2,
        mime="application/json",
    )

Your code works for me. When one of the buttons is used, the app reloads and then I can use the other button.

Hello @Goyo!
For me the app reloads and both buttons disappear.
What could cause that…?

The other code in your app. Try running just the code you posted here.

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