Skip to content

Commit

Permalink
Merge branch 'feat/upload-image-to-s3' of github.com:hotosm/fmtm into…
Browse files Browse the repository at this point in the history
… feat/upload-image-to-s3
  • Loading branch information
Sujanadh committed Aug 9, 2024
2 parents b9c328f + 37f146e commit 52689f9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/backend/app/submissions/submission_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,19 +602,19 @@ async def upload_attachment_to_s3(

for idx, filename in enumerate(attachments):
s3_key = f"{s3_base_path}/{instance_id}/{idx+1}.jpeg"

if object_exists(s3_bucket, s3_key):
log.warning(
f"Object {s3_key} already exists in S3. Skipping upload."
)
continue

try:
if attachment:= xform.getSubmissionPhoto(
project.odkid,
str(instance_id),
db_xform.odk_form_id,
str(filename)
if attachment := xform.getSubmissionPhoto(
project.odkid,
str(instance_id),
db_xform.odk_form_id,
str(filename),
):
# Convert the attachment to a BytesIO stream
image_stream = io.BytesIO(attachment)
Expand Down Expand Up @@ -650,7 +650,7 @@ async def upload_attachment_to_s3(
except Exception as e:
log.warning(
f"Failed to process {filename} for instance {instance_id}: {e}"
)
)
continue

db.commit()
Expand Down

0 comments on commit 52689f9

Please sign in to comment.