Skip to content

Commit

Permalink
Merge pull request #114 from whyphi/staging
Browse files Browse the repository at this point in the history
Release: `2.0.3`
  • Loading branch information
wderocco8 authored Sep 13, 2024
2 parents bd5bb89 + c13f263 commit d8fa1f9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions chalicelib/services/EventsRushService.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def modify_rush_event(self, data: dict):
data["lastModified"] = datetime.datetime.now()
data["_id"] = event_oid

# get image versions
# get existing image and image versions
eventCoverImage: str = data["eventCoverImage"]
eventCoverImageVersion = data["eventCoverImageVersion"]
prevEventCoverImageVersion = get_prev_image_version(version=eventCoverImageVersion)

Expand All @@ -94,14 +95,16 @@ def modify_rush_event(self, data: dict):
image_path = f"image/rush/{event_category_id}/{event_id}/{eventCoverImageVersion}.png"
prev_image_path = f"image/rush/{event_category_id}/{event_id}/{prevEventCoverImageVersion}.png"

# remove previous eventCoverImage from s3 bucket
s3.delete_binary_data(object_id=prev_image_path)

# upload eventCoverImage to s3 bucket
image_url = s3.upload_binary_data(path=image_path, data=data["eventCoverImage"])
# only need to re-upload and delete old image if eventCoverImage does NOT contain https://whyphi-zap.s3.amazonaws.com
if "https://whyphi-zap.s3.amazonaws.com" not in eventCoverImage:
# remove previous eventCoverImage from s3 bucket
s3.delete_binary_data(object_id=prev_image_path)

# upload eventCoverImage to s3 bucket
image_url = s3.upload_binary_data(path=image_path, data=eventCoverImage)

# add image_url to data object (this also replaces the original base64 image url)
data["eventCoverImage"] = image_url
# add image_url to data object (this also replaces the original base64 image url)
data["eventCoverImage"] = image_url

# Merge data with event (from client + mongo) --> NOTE: event must be unpacked first so
# that data overrides the matching keys
Expand Down

0 comments on commit d8fa1f9

Please sign in to comment.