Load and Display Files from Local Storage

Hey Guys,

I have a file manager that lists all uploaded files from the upload section.
My question is, how can I retrieve my files from my tempDir and display them?
os.open just gives me a string than the actual data:

below is my code:

 # my files menu
    if (choice == menu[1]):
        col1, col2, col3 = st.columns([4, 1, 1])
        fileList = []
        filePaths = []
        fileId = 0

        for root, dirs, files in os.walk("tempDir"):
            for file in files:
                filePath = os.path.join(root, file)
                fileName = os.path.join(file)
                fileList.append(fileName)
                filePaths.append(filePath)
        for item in fileList:
            fileKey = "fileKey_{}".format(fileId)
            with st.expander(item):
                with open(filePaths[fileId], 'rb') as file:             
                    agree = st.checkbox('Display Data 📊', key=fileKey)
                    if agree:
                        st.write(file)
                        st.download_button("Download", item, key=fileKey)
                fileId += 1

        st.selectbox("Select Item", fileList)
        with st.expander("Raw Output"):
            st.write(fileList)

Hi @fuccDebugging -

I’m not sure I understand your question. You are retrieving files from the local filesystem and open doesn’t work?

Best,
Randy

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