Streamlit application - Download_button error

Summary

I have a simple streamlit application with a upload button for uploading excel file and a download_button for downloading the processed dataframe as an excel file. This application works fine when run locally as well as from a docker container. But when I deploy the docker image thro kubernetes, the download_button gives a permission error

Steps to reproduce

Code snippet:

download_button(censusdf, up_filename, 'Download Excel')

Working good locally or through docker run. But deployed through Kubernets ends up with a permission error.
Expected behavior:

It should allow to download the file.

Actual behavior:

The download_button has this error.

<<PermissionError: [Errno 13] Permission denied: ‘CensustiersampleV1.xlsx’ raceback:

File "/usr/local/lib/python3.8/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)File "/app/salesassistant.py", line 55, in <module>
    run_app()File "/app/salesassistant.py", line 51, in run_app
    app_main(applist)File "/app/censustierstreamlit/censustierNew.py", line 274, in main
    download_button(censusdf, up_filename, 'Download Excel')File "/app/censustierstreamlit/censustierNew.py", line 206, in download_button
    wb.save(filename)File "/usr/local/lib/python3.8/site-packages/openpyxl/workbook/workbook.py", line 386, in save
    save_workbook(self, filename)File "/usr/local/lib/python3.8/site-packages/openpyxl/writer/excel.py", line 291, in save_workbook
    archive = ZipFile(filename, 'w', ZIP_DEFLATED, allowZip64=True)File "/usr/local/lib/python3.8/zipfile.py", line 1251, in __init__
    self.fp = io.open(file, filemode)
```>>


### Debug info

- Streamlit version: 1.20.0
- Python version: 3.8

- Browser version: Version 116.0.5845.110 (Official Build) (arm64)

### Requirements file

certifi==2021.10.8

openpyxl==3.1.2

pandas==1.4.2

pymongo==3.12.0

protobuf==3.19.0

sklearn-pandas==2.2.0

streamlit==1.20.0

streamlit-aggrid==0.2.3.post2

urllib3==1.26.15

sqlalchemy==1.4.35

psycopg2-binary

python-dotenv

usaddress

uszipcode

python-Levenshtein

### Links

If I know where the download_button is trying to write / save the file, I can set the permissions through my docker file.   Any help is much appreciated.

Thanks,
Ramaiah

Hi @rradhakrishnan

Have you also defined the mime parameter for the Excel file, particularly application/vnd.ms-excel (according to Which MIME type to download Excel files?)?

You can try the kubectl exec command to get a shell inside the container and check the permissions, looks a permissions issue

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.