Hello, I am currently trying to allow users of my app to pull certain files from a supabase storage bucket I have. The idea is to take a user’s text input and then pull the file with that name and graph the data on it. I will put what I code I have so far but I am struggling with using session state to clear the text associated with the file variable. How could I make it to where the code would search for a file with the entered name and then plot it on a bar graph (the files would consist of two columns, hours and angles). I know the code I have right now should just download the specified file, but was just trying this out before moving on to plotting.
import streamlit as st
import supabase
from supabase import create_client, Client
url = "url"
key ="key"
supabase = supabase.create_client(url, key)
bucket_name = "bucket"
file_name = st.empty()
file_name.text_input("Please enter the patient's ID", value="", key="1")
#file_name = st.text_input("Please enter the patient's ID number")
# Download the file
try:
response = supabase.storage.from_(bucket_name).download(file_name)
# Check for errors
if response.error:
raise Exception(response.error.message)
# Save the file locally
with open(file_name, "wb") as file:
file.write(response.data)
st.write(f"File '{file_name}' downloaded successfully.")
except Exception as e:
st.write(f"Error downloading file: {e}")