How do I zip uploaded files for download?

I have created an Image processing application where the user uploads images and selects anchor images based on which the ML Model groups the pictures into a dictionary (with anchors being the keys and the corresponding images as lists are the values) by similarity. It then displays the anchor images and their corresponding groups. I am facing the issue of downloading those groups by a single download button for each group. I am trying to zip them but it constantly gives : TypeError: stat: path should be string, bytes, os.PathLike or integer, not UploadedFile. Any help would be highly appreciated :slight_smile:

Het @Rafay_Farhan

You should check the st.file_uploader - Streamlit Docs documentation for manipulation the UploadedFile class, if you want the Bytes representation of your uploaded image for example you should use the .getvalue() method :wink:

Happy Streamlitin’,

1 Like


Thank you so much for the reply. There still seems to be an issue though ValueError: stat: embedded null character in path