taolib.testing.file_storage.processing.validator#
默认文件验证器。
实现 FileValidatorProtocol,提供 MIME 检测、大小验证和安全检查。
Attributes#
Classes#
默认文件验证器实现。 |
Functions#
|
通过 magic bytes 和文件扩展名检测 MIME 类型。 |
|
将 MIME 类型分类为 MediaType。 |
Module Contents#
- taolib.testing.file_storage.processing.validator._DANGEROUS_MIME_TYPES#
- taolib.testing.file_storage.processing.validator._MAGIC_SIGNATURES: list[tuple[bytes, str]] = [(b'\x89PNG\r\n\x1a\n', 'image/png'), (b'\xff\xd8\xff', 'image/jpeg'), (b'GIF87a', 'image/gif'),...#
- taolib.testing.file_storage.processing.validator._MEDIA_TYPE_MAP: dict[str, taolib.testing.file_storage.models.enums.MediaType]#
- taolib.testing.file_storage.processing.validator._detect_content_type(header_bytes: bytes, filename: str) str#
通过 magic bytes 和文件扩展名检测 MIME 类型。
- taolib.testing.file_storage.processing.validator._classify_media_type(content_type: str) taolib.testing.file_storage.models.enums.MediaType#
将 MIME 类型分类为 MediaType。
- class taolib.testing.file_storage.processing.validator.DefaultFileValidator#
默认文件验证器实现。