Spaces:
Sleeping
Sleeping
File size: 530 Bytes
718f018 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | from supabase import create_client
from django.conf import settings
import uuid
def upload_to_supabase(image_file):
supabase = create_client(settings.SUPABASE_URL, settings.SUPABASE_KEY)
filename = f"{uuid.uuid4()}.{image_file.name.split('.')[-1]}"
file_content = image_file.read()
supabase.storage.from_("xrays").upload(
file=file_content,
path=filename,
file_options={"content-type": image_file.content_type}
)
return supabase.storage.from_("xrays").get_public_url(filename) |