Deleting From Storage in Python

This is slightly strange as I know most people don't do supabase queries in python but lets assume file_path is 100% the name of the item in storage. why is this not deleting the file in that bucket?

def delete_media(media):
try:
file_path = media.split(MEDIA_PATH)[-1].split("?")[0]
logging.info(f"FILEPATH: {filepath}")

response = supabase.storage.from
(BUCKET_NAME).remove([file_path])

logging.info(f"DELETE MEDIA RESPONSE: {response}")
if not response:
logging.info(f"Successfully deleted the file from storage: {file_path}")
else:
logging.error("Error deleting media")
except Exception as e:
logging.error(f"Error deleting file: {str(e)}")


INFO:root:DELETE MEDIA RESPONSE: []
ERROR:root:Error deleting file: 'list' object has no attribute 'data'
Was this page helpful?