Which MIME type to download Excel files?

Hello,

I have some trouble using the “download_button” feature with an Excel file.
Below is the code I am using.

It works fine when I run streamlit on my machine. However, when I deploy it on the remote server (docker image hosted on azure), users are redirected to an empty page with “404: Not Found” message when they click on the download button.

I suspect it is a MIME type problem but I have no idea which one to use.

Thanks in advance for any idea that could help me fix this :slight_smile:

            with open(output_file, "rb") as fp:
                status.subheader(":thumbsup: The simulation is done ! You can download the results using the button below")
                download_button_place_holder.download_button(
                label="Download Excel",
                data=fp,
                file_name="outputs.xlsx",
                mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")

Per this site, this appears to be the right MIME:

application/vnd.ms-excel

Best,
Randy

2 Likes

Thank you very much Randy.
It works now both on my machine and on the server side.