Downloading a MS Word document

I have an app that allows to edit an uploaded Word document. The edits would need to be saved as a separate document and then saved. To accomplish this I use the st.download_button. However, when I run the code I get this error: RuntimeError: Invalid binary data format: <class ‘NoneType’>. And this one as well: RuntimeError(“Invalid binary data format: %s” % type(data)).

Why do these errors occur? Any form of help would be appreciated.

I am using Python 3.10.4, Streamlit 1.11.1, Virtualenv, PyCharm Community Edition 2022.1.4, Windows 11, Firefox 103.0.1 (64-bit).

My code for the download button is shown here:

st.download_button(label='Download Edits', data=edited_doc, file_name='EDITED.docx', mime='application/octet-stream', key=321)

1 Like

if you find a solution pls tell