Download function for streamlit app

I have a download function for users to download zip files of pandas df that has been converted to csv. But unfortunately it also save it to my local folder. Is there anyway to prevent this?

def downloader(list_df, datafile, file_type):

    file =".")[0]
    #create zip file
    with zipfile.ZipFile("{}.zip".format(file), 'w', zipfile.ZIP_DEFLATED) as file_zip:

        for i in range(len(list_df)):
            file_zip.writestr(file+"_group_{}".format(i)+".csv", pd.DataFrame(list_df[i]).to_csv())

    #pass it to front end for download
    zip_name = "{}.zip".format(file)

    with open(zip_name, "rb") as f:
        b64 = base64.b64encode(bytes).decode()
        href = f'<a href=\"data:file/zip;base64,{b64}\" download="{zip_name}">Click Here To Download</a>'
        st.markdown(href, unsafe_allow_html=True)

Hi @ds96,

You may want to try this code snippet:

Let us know how it goes! :raised_hands:


Thank you !