From 9f29131b7079f8615068b2d0b41be880c77daa54 Mon Sep 17 00:00:00 2001 From: Joel Balcaen Date: Tue, 23 Apr 2024 16:54:54 -0300 Subject: [PATCH] fix storage path --- lambdas/email_attachment_saver/src/index.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lambdas/email_attachment_saver/src/index.py b/lambdas/email_attachment_saver/src/index.py index 294ed5e..21a8923 100644 --- a/lambdas/email_attachment_saver/src/index.py +++ b/lambdas/email_attachment_saver/src/index.py @@ -36,12 +36,12 @@ def lambda_handler(event, context): for part in msg.walk(): if part.get_content_maintype() != 'multipart' and part['Content-Disposition'] is not None: try: - key = part.get_filename() - s3.put_object(Bucket=bucket, Key=s3_folder + - key, Body=part.get_payload(decode=True)) + key = "/".join([s3_folder,part.get_filename()]) + logger.info(f"Putting object in bucket:{bucket} and key:{key}") + s3.put_object(Bucket=bucket, Key=key, Body=part.get_payload(decode=True)) file_extension = key.split('.')[-1] if '.' in key else None attachment_arns.append({ - 'path': 'arn:aws:s3:::' + bucket + '/' + s3_folder + '/' + key, + 'path': 'arn:aws:s3:::' + bucket + '/' + key, 'extension': file_extension })