1.5.0 breaks ability to download files

Pre 1.5.0 I was able to implement the ability to download a file (specifically .xlsx) in the directory with this code.

st.markdown(download(name), unsafe_allow_html=True)
def download(file):

    with open(file, 'rb') as f:
       data = f.read()
    bin64 = base64.b64encode(data).decode()
    return f"<a href='data:application/octet-stream;base64,{bin64}' download='{os.path.basename(file)}'><input type='button' value='Download'></a>"

However it no longer works in 1.5.0 - the download doesn’t process and the browser returns an about:blank#blocked page - some kind of security feature?

I don’t think we specifically went out of our way to block this sort of behavior, but we do support a download button now, which should be a much better and stable way of doing this:

Best,
Randy

Turns out this is a bug:

I would still suggest using st.download_button though.

Best,
Randy

Thanks Randy,

I knew of the download widget but not able to use it since I need the button in a form and I can only use one button in a form (I think this behavior should be changed?)