supabase storage pyhon can't upsert or handle exceptions

15 views Asked by At

I'm trying to upload a file in supabase storage, but it seems that if a file is already there then I get an exception StorageException "The resource already exists". It happens despite the fact that I have "upsert" : "true" file option, and also the statement is inside a try .. except block but the except doesnt catch the exception:

    try:             
        result = supabase.storage.from_(STORAGE_BUCKET).upload(file=f, path=storagepath+'/'+basename, file_options={"content-type": "image/jpeg", "cache-control": "3600", "upsert": "true"})
     except Exception as err:
          strErr = str(err)
          if "Duplicate" not in strErr:
              raise Exception from err

enter image description here

0

There are 0 answers