Skip to content

Commit

Permalink
add fetch file logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Balcaen committed Apr 5, 2024
1 parent 476f5df commit c629015
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions lambdas/rich_pdf_ingestion/src/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import boto3
from pypdf import PdfReader
import json
from botocore.exceptions import NoCredentialsError, BotoCoreError, ClientError


OBJECT_CREATED = "ObjectCreated"
Expand Down Expand Up @@ -30,17 +30,17 @@ def fetch_file(bucket, key):
s3 = boto3.client("s3")
local_filename = f"/tmp/{key.split('/')[-1]}"


s3.download_file(bucket, key, local_filename)
# except NoCredentialsError as e:
# print(e)
# raise e
# except BotoCoreError as e:
# print(e)
# raise e
# except ClientError as e:
# print(e)
# raise e
try:
s3.download_file(bucket, key, local_filename)
except NoCredentialsError as e:
print(e)
raise e
except BotoCoreError as e:
print(e)
raise e
except ClientError as e:
print(e)
raise e
return local_filename


Expand All @@ -56,6 +56,7 @@ def lambda_handler(event, context):

if eventName.startswith(OBJECT_CREATED):
local_filename = fetch_file(bucket, key)


# collection_name = bucket + "-"
# collection_name += os.path.dirname(key).replace("/", "-")
Expand Down

0 comments on commit c629015

Please sign in to comment.