Skip to content

Commit

Permalink
fix: correctly set org logo url on update
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Nov 27, 2023
1 parent 0e7fd36 commit 73926ad
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/backend/app/organization/organization_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async def upload_logo_to_s3(
logo_file(UploadFile): The logo image uploaded to FastAPI.
Returns:
logo_path(str): The file path in S3.
logo_url(str): The S3 URL for the logo file.
"""
logo_path = f"/{db_org.id}/logo.png"

Expand All @@ -88,7 +88,9 @@ async def upload_logo_to_s3(
content_type=logo_file.content_type,
)

return logo_path
logo_url = f"{settings.S3_DOWNLOAD_ROOT}/{settings.S3_BUCKET_NAME}{logo_path}"

return logo_url


async def create_organization(
Expand Down Expand Up @@ -124,12 +126,8 @@ async def create_organization(
# Refresh to get the assigned org id
db.refresh(db_organization)

logo_path = await upload_logo_to_s3(db_organization, logo)

# Update the logo field in the database with the correct path
db_organization.logo = (
f"{settings.S3_DOWNLOAD_ROOT}/{settings.S3_BUCKET_NAME}{logo_path}"
)
db_organization.logo = await upload_logo_to_s3(db_organization, logo)
db.commit()

except Exception as e:
Expand Down

0 comments on commit 73926ad

Please sign in to comment.