Enum Class FileValidationError
- All Implemented Interfaces:
Serializable, Comparable<FileValidationError>, Constable
文件校验错误枚举
每个枚举项对应一类文件上传安全校验失败,携带稳定的业务错误码(code)、
可读的默认错误信息(message)以及映射的 HTTP 状态码。
业务错误码与 HTTP 状态码解耦:HTTP 层面统一为 HttpStatus.BAD_REQUEST(400),
业务系统可依据 code 做精细化分支处理(如前端按错误码展示不同提示)。
- Author:
- kerbores(kerbores@gmail.com)
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescription文件为空(无任何字节)扩展名命中黑名单文件扩展名声明的类型与内容真实类型不一致(伪装文件)扩展名不在白名单文件名为空或仅空白文件名超出长度限制文件名包含 XSS 攻击字符文件内容检测出的真实 MIME 与允许类型不符文件名包含路径穿越语义文件大小超出上限文件大小低于下限(防空壳/占位文件) -
Method Summary
Modifier and TypeMethodDescriptionstatic FileValidationErrorReturns the enum constant of this class with the specified name.static FileValidationError[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
EMPTY_FILE
文件为空(无任何字节) -
SIZE_EXCEEDED
文件大小超出上限 -
SIZE_TOO_SMALL
文件大小低于下限(防空壳/占位文件) -
EXT_BLOCKED
扩展名命中黑名单 -
EXT_NOT_ALLOWED
扩展名不在白名单 -
MIME_MISMATCH
文件内容检测出的真实 MIME 与允许类型不符 -
EXT_MIME_INCONSISTENT
文件扩展名声明的类型与内容真实类型不一致(伪装文件) -
FILENAME_EMPTY
文件名为空或仅空白 -
FILENAME_TOO_LONG
文件名超出长度限制 -
FILENAME_XSS
文件名包含 XSS 攻击字符 -
PATH_TRAVERSAL
文件名包含路径穿越语义
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-