Upload and write any file type (File_Uploader&Textract)

Hi everyone and thank you for the awesome work in developing streamlit. Ive been trying to build a an app which can upload any file type, process it through textract (mostly where i face the issues), write through st write and then summarize the uploaded part. The problem is that whenever i try to upload the file i receive the following error:

Also, whenever the file is uploaded and ran through textract i receive the following:

So its unable for any file to be read and processed for the summarizer. Below im sending the code ive been using for this model:
def file_selector(folder_path=’.’):

filenames = os.listdir(folder_path)

selected_filename = st.selectbox('Select a file', filenames)

return os.path.join(folder_path, selected_filename)


def main():
st.title("Summarizer Tool")
st.subheader("Summarize Uploaded File")
uploaded_file = st.file_uploader("Upload File",)
if st.button('Upload'):
    txt =''.join(filename)
    text = tx.process(txt)

Any input would be highly appreciated.

My guess is you’re mixing up strings and bytes with opening and writing files. Can you share a smaller example setup? Your code as posted takes a local filename as input and ignores the uploaded file.

streamlit has a fileuploader option you can use.