Validate uploaded logo file size and MIME type.
(file)
| 20 | |
| 21 | |
| 22 | def validate_logo_file(file): |
| 23 | """Validate uploaded logo file size and MIME type.""" |
| 24 | valid_mime_types = ["image/jpeg", "image/png", "image/gif", "image/webp", "image/svg+xml"] |
| 25 | if file.content_type not in valid_mime_types: |
| 26 | raise ValidationError("Unsupported file type. Allowed types: JPEG, PNG, GIF, WebP, SVG.") |
| 27 | if file.size > 5 * 1024 * 1024: # 5MB |
| 28 | raise ValidationError("File too large. Max 5MB.") |
| 29 | |
| 30 | |
| 31 | def get_client_ip(request): |