File size: 671 Bytes
7535d0e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from supabase_models import Supabase_Client


def store_message_data(message_id:str , attachment_id:str):
    if attachment_id and message_id:
        extension = attachment.filename.split(".")[-1]
        file_name = f"{message.id}_{attachment.attachment_id}.{extension}"
        print(f"file_name: {file_name}")
        supabase = Supabase_Client().instance
        try:
          response = supabase.storage.from_("receipt_radar").download(
              file_name
            )
          base64_data = urlsafe_b64encode(response).decode('utf-8')
          return base64_data
        except Exception as e:
            print(f"Error downloading or encoding file: {e}")