mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 14:09:20 -04:00
Add max file size check when uploading a letter
This commit is contained in:
@@ -9,6 +9,8 @@ from app.main import main
|
||||
from app.main.forms import PDFUploadForm
|
||||
from app.utils import user_has_permissions
|
||||
|
||||
MAX_FILE_UPLOAD_SIZE = 2 * 1024 * 1024 # 2MB
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/uploads")
|
||||
@user_has_permissions('send_messages')
|
||||
@@ -29,6 +31,10 @@ def upload_letter(service_id):
|
||||
flash('Your file has failed the virus check', 'dangerous')
|
||||
return render_template('views/uploads/choose-file.html', form=form), 400
|
||||
|
||||
if len(pdf_file_bytes) > MAX_FILE_UPLOAD_SIZE:
|
||||
flash('Your file must be smaller than 2MB', 'dangerous')
|
||||
return render_template('views/uploads/choose-file.html', form=form), 400
|
||||
|
||||
upload_id = uuid.uuid4()
|
||||
|
||||
return redirect(
|
||||
|
||||
Reference in New Issue
Block a user