Show letter preview once file is uploaded

This shows the sanitised letter preview if the file had no validation
errors or the preview with the overlay if it failed validation.
This commit is contained in:
Katie Smith
2019-09-09 10:59:32 +01:00
parent 8a322b844b
commit 7368245c9a
9 changed files with 228 additions and 6 deletions

View File

@@ -1,3 +1,4 @@
from boto3 import resource
from flask import current_app
from notifications_utils.s3 import s3upload as utils_s3upload
@@ -14,3 +15,13 @@ def upload_letter_to_s3(data, file_location, status):
file_location=file_location,
metadata={'status': status}
)
def get_letter_pdf_and_metadata(file_location):
s3 = resource('s3')
s3_object = s3.Object(current_app.config['TRANSIENT_UPLOADED_LETTERS'], file_location).get()
pdf = s3_object['Body'].read()
metadata = s3_object['Metadata']
return pdf, metadata