mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-04 16:11:11 -04:00
Backup original precompiled uploads to S3
This continues the work from Template Preview [1], so that we have a complete store of original PDFs to use for testing changes to it. Previously we did store some originals, but these were only invalid PDFs that had failed sanitisation; for valid PDFs, the "transient" bucket only contains the sanitised versions, which the API deletes / moves when the notification is sent [2]. Since the notification is only created at a later stage [3], there's no easy way to get the final name of the PDF we send to DVLA. Instead, we use the "upload_id", which eventually becomes the notification ID [4]. This should be enough to trace the file for specific debugging. Note that we only want to store original PDFs if they're valid (and virus free!), since there's no point testing changes with bad data. [1]: https://github.com/alphagov/notifications-template-preview/pull/545 [2]:c44ec57c17/app/service/send_notification.py (L212)[3]:7930a53a58/app/main/views/uploads.py (L362)[4]:7930a53a58/app/main/views/uploads.py (L373)
This commit is contained in:
@@ -39,6 +39,7 @@ from app.main import main
|
||||
from app.main.forms import CsvUploadForm, LetterUploadPostageForm, PDFUploadForm
|
||||
from app.models.contact_list import ContactList
|
||||
from app.s3_client.s3_letter_upload_client import (
|
||||
backup_original_letter_to_s3,
|
||||
get_letter_metadata,
|
||||
get_letter_pdf_and_metadata,
|
||||
get_transient_letter_file_location,
|
||||
@@ -216,6 +217,11 @@ def upload_letter(service_id):
|
||||
filename=original_filename,
|
||||
recipient=recipient)
|
||||
|
||||
backup_original_letter_to_s3(
|
||||
pdf_file_bytes,
|
||||
upload_id=upload_id,
|
||||
)
|
||||
|
||||
return redirect(
|
||||
url_for(
|
||||
'main.uploaded_letter_preview',
|
||||
|
||||
Reference in New Issue
Block a user