from django.core.exceptions import ValidationError

def validate_file_size(value):
    filesize = value.size  # in bytes
    
    if filesize > 40 * 1024 * 1024:  # 40MB = 40 * 1024 * 1024 bytes
        raise ValidationError("The maximum file size that can be uploaded is 40MB")
    return value
