mirror of
https://github.com/GSA/notifications-admin.git
synced 2025-12-08 14:14:27 -05:00
22 lines
548 B
Python
22 lines
548 B
Python
import base64
|
|
|
|
DOCUMENT_UPLOAD_SIZE_LIMIT = 2 * 1024 * 1024
|
|
|
|
|
|
def prepare_upload(
|
|
f, filename=None, confirm_email_before_download=None, retention_period=None
|
|
):
|
|
contents = f.read()
|
|
|
|
if len(contents) > DOCUMENT_UPLOAD_SIZE_LIMIT:
|
|
raise ValueError("File is larger than 2MB")
|
|
|
|
file_data = {
|
|
"file": base64.b64encode(contents).decode("ascii"),
|
|
"filename": filename,
|
|
"confirm_email_before_download": confirm_email_before_download,
|
|
"retention_period": retention_period,
|
|
}
|
|
|
|
return file_data
|