FileNotFoundError with File_uploader()

Hi,
I have deployed a simple streamlit app on community cloud(link to the app). It asks for multiple files and downloads a merged pdf of the two.

The github repository is here

I ran the app before deployment and I could see that the file uploader works only when files are uploaded from the working directory.
But now when I deploy, I want to let the user upload files from anywhere and be able to merge them. But instead I get errors like this:

FileNotFoundError: [Errno 2] No such file or directory: 'File 1.pdf'

The streamlit version is 1.27(requirements.txt file in the github repo) and python version is 3.11.
what do I need to do to make FIle_uploader() proces files from anywhere and not just the working directory?

The return type of st.file_uploader is not a list of files on the hard drive, but a list of BytesIO objects.

Therefore you cannot read these files by name from the hard drive.
I haven’t tried it, but PyPDF2.PdfReader should also accept a BytesIO object as argument, therefore this could work:

pdf_reader_list = [PyPDF2.PdfReader(file) for file in file_list]

Oh yes it worked! thank you!

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