When I run my streamlit app (deployed in cloud) when I click st.download_button it shows me:
2026-06-17 14:47:32.803 200 GET /media/883802cc33ba652d752ebaf82e8bea14ef913f4175e878affbe1566c.pdf (10.116.0.6) 3.47ms
In the logs.
However the the download fails with the browser complaining 404 error, not found.
Can you explain what this media file is and why it cannot be found?
The download code is as follows:
pdf_path = os.path.join(st.session_state.image_path, "Analysis_Report.pdf")
PDFbyte = None
if os.path.isfile(pdf_path):
with open(pdf_path, "rb") as pdf_file:
PDFbyte = pdf_file.read()
if PDFbyte:
tm.sleep(6)
st.download_button(
label="PDF Report",
data=PDFbyte,
#data=pdf_file,
file_name= idea_id+"_Analysis_Report.pdf",
mime="application/pdf",
#mime = "application/octet-stream",
key = "pdf_download",
on_click='ignore',
icon = ":material/download:",
)
else:
st.error("Analysis Report PDF not created.")
This code works sometimes but it is a hit or miss.
Quite frustrated.
Sudipta Bhawmik