Documentation
¶
Overview ¶
Package upload 提供 multipart 文件上传封装: 大小/扩展名校验 + 存储联动(对象存储或本地目录)+ 统一文件信息返回。 场景:直播封面、头像、附件上传。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// MaxSize 单文件大小上限(字节),0 表示不限制。
MaxSize int64
// AllowedExt 允许的扩展名(小写,如 ".jpg" ".png");空表示不限制。
AllowedExt []string
}
Config 上传配置。
type FileInfo ¶
type FileInfo struct {
// Name 原始文件名。
Name string
// Ext 扩展名(小写,含点)。
Ext string
// Size 文件大小(字节)。
Size int64
// Content 文件内容(小文件场景直接使用;大文件建议先落盘)。
Content []byte
// Header 原始 multipart 头。
Header *multipart.FileHeader
}
FileInfo 上传文件信息。
Click to show internal directories.
Click to hide internal directories.