Class UploadHandler.UploadConfig
java.lang.Object
com.wontlost.ckeditor.handler.UploadHandler.UploadConfig
- Enclosing interface:
UploadHandler
上传配置
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long默认最大文件大小:10MBstatic final long最大允许的文件大小:1GBstatic final long最小允许的文件大小:1 字节 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAllowedMimeTypes(String... mimeTypes) 添加额外的 MIME 类型到允许列表String[]获取允许的 MIME 类型long获取最大文件大小重置为默认的 MIME 类型列表setAllowedMimeTypes(String... allowedMimeTypes) 设置允许的 MIME 类型。setMaxFileSize(long maxFileSize) 设置最大文件大小validate(UploadHandler.UploadContext context) 验证上传是否符合配置
-
Field Details
-
MIN_FILE_SIZE
public static final long MIN_FILE_SIZE最小允许的文件大小:1 字节- See Also:
-
MAX_FILE_SIZE_LIMIT
public static final long MAX_FILE_SIZE_LIMIT最大允许的文件大小:1GB- See Also:
-
DEFAULT_MAX_FILE_SIZE
public static final long DEFAULT_MAX_FILE_SIZE默认最大文件大小:10MB- See Also:
-
-
Constructor Details
-
UploadConfig
public UploadConfig()
-
-
Method Details
-
getMaxFileSize
public long getMaxFileSize()获取最大文件大小- Returns:
- 最大文件大小(字节)
-
setMaxFileSize
设置最大文件大小- Parameters:
maxFileSize- 最大文件大小(字节),必须在 1 字节到 1GB 之间- Returns:
- this
- Throws:
IllegalArgumentException- 如果 maxFileSize 超出有效范围
-
getAllowedMimeTypes
-
setAllowedMimeTypes
设置允许的 MIME 类型。 设置为空数组将允许所有 MIME 类型。- Parameters:
allowedMimeTypes- MIME 类型数组- Returns:
- this
- Throws:
IllegalArgumentException- 如果数组为 null 或包含 null/空字符串
-
addAllowedMimeTypes
添加额外的 MIME 类型到允许列表- Parameters:
mimeTypes- 要添加的 MIME 类型- Returns:
- this
-
resetAllowedMimeTypes
-
validate
验证上传是否符合配置- Parameters:
context- 上传上下文- Returns:
- 验证失败的错误消息,验证成功返回 null
-