Skip to content

Commit

Permalink
add file extension to saved filed
Browse files Browse the repository at this point in the history
  • Loading branch information
joelbalcaen committed Apr 22, 2024
1 parent b081d39 commit 36ad015
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lambdas/email_attachment_saver/src/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ def lambda_handler(event, context):
key = part.get_filename()
s3.put_object(Bucket=bucket, Key=s3_folder +
key, Body=part.get_payload(decode=True))
attachment_arns.append(
'arn:aws:s3:::' + bucket + '/' + s3_folder + '/' + key)
file_extension = key.split('.')[-1] if '.' in key else None
attachment_arns.append({
'path': 'arn:aws:s3:::' + bucket + '/' + s3_folder + '/' + key,
'extension': file_extension
})

except NoCredentialsError:
logger.error('No AWS credentials found')
Expand Down

0 comments on commit 36ad015

Please sign in to comment.