mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 08:51:30 -05:00
DRY-up pre-existing method to get PDF body/meta
This is possible now that the "find_..." method returns an S3 object.
This commit is contained in:
@@ -186,16 +186,7 @@ def get_file_names_from_error_bucket():
|
|||||||
|
|
||||||
|
|
||||||
def get_letter_pdf_and_metadata(notification):
|
def get_letter_pdf_and_metadata(notification):
|
||||||
bucket_name, prefix = get_bucket_name_and_prefix_for_notification(notification)
|
obj = find_letter_pdf_in_s3(notification).get()
|
||||||
|
|
||||||
s3 = boto3.resource('s3')
|
|
||||||
bucket = s3.Bucket(bucket_name)
|
|
||||||
item = next(x for x in bucket.objects.filter(Prefix=prefix))
|
|
||||||
|
|
||||||
obj = s3.Object(
|
|
||||||
bucket_name=bucket_name,
|
|
||||||
key=item.key
|
|
||||||
).get()
|
|
||||||
return obj["Body"].read(), obj["Metadata"]
|
return obj["Body"].read(), obj["Metadata"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user