Uploading ZipFiles

Hi community, Iā€™m trying to upload a zip file to my app, using this:

uploaded_zip = st.file_uploader('XML File', type="zip", encoding="latin1")
        if (uploaded_zip is not None):
            zf = zipfile.ZipFile(uploaded_zip)

And returngin ā€œBadZipFile: File is not a zip fileā€
Can I use this?

Hi rfgallon,

I canā€™t reproduce your error with the given code snippet and a random zip file from my local machine.

Therefore, I assume that this is not a streamlit issue, but rather something about your zip file that zipfile.ZipFile() canā€™t handle. Maybe this thread is helping you: https://stackoverflow.com/questions/3083235/unzipping-file-results-in-badzipfile-file-is-not-a-zip-file.

Best wishes,
Marcus

1 Like