mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-27 03:44:19 +00:00
10 lines
352 B
Python
10 lines
352 B
Python
from wtforms.validators import ValidationError
|
|
|
|
def FileSizeLimit(max_size_in_mb):
|
|
max_bytes = max_size_in_mb*1024*1024
|
|
def file_length_check(form, field):
|
|
if len(field.data.read()) > max_bytes:
|
|
raise ValidationError(f"File size must be less than {max_size_in_mb}MB")
|
|
field.data.seek(0)
|
|
return file_length_check
|