Documentation ¶
Index ¶
- Variables
- type Attachment
- func (a *Attachment) Error() error
- func (a *Attachment) Errors() []error
- func (a *Attachment) HasError() bool
- func (a *Attachment) Save() *Attachment
- func (a *Attachment) SetBeforeSave(fn func(a *Attachment) bool) *Attachment
- func (a *Attachment) ToMedia(src string, args ...interface{}) string
- func (a *Attachment) Upload(opt *Options) *Attachment
- type Options
Constants ¶
This section is empty.
Variables ¶
View Source
var Types = map[string]*typeInfo{ "image": { TypeName: "图片", AllowExt: []string{".gif", ".jpg", ".jpeg", ".bmp", ".png", ".ico"}, MaxSize: 5 * 1024 * 1024, }, "voice": { TypeName: "音频", AllowExt: []string{".mp3", ".wma", ".wav", ".amr"}, MaxSize: 50 * 1024 * 1024, }, "video": { TypeName: "视频", AllowExt: []string{".rm", ".rmvb", ".wmv", ".avi", ".mpg", ".mpeg", ".mp4"}, MaxSize: 300 * 1024 * 1024, }, "office": { TypeName: "办公文件", AllowExt: []string{ ".wps", ".wpt", ".doc", ".dot", ".docx", ".docm", ".dotm", ".et", ".ett", ".xls", ".xlt", ".xlsx", ".xlsm", ".xltx", ".xltm", ".xlsb", ".dps", ".dpt", ".ppt", ".pps", ".pot", ".pptx", ".ppsx", ".potx", ".txt", ".csv", ".prn", ".pdf", ".xml", }, MaxSize: 50 * 1024 * 1024, }, "zip": { TypeName: "压缩文件", AllowExt: []string{".zip", ".rar"}, MaxSize: 500 * 1024 * 1024, }, }
Types 附件类型
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment struct { Opt *Options // 附件实例化时的参数选项 GinContext *gin.Context // gin上下文 BaseConfig *jcbaseGo.AttachmentStruct // 附件配置信息 RemoteConfig interface{} // 远程附件配置 FileType string // 附件类型 FileName string // 附件名 FileSize int64 // 附件大小 FileAttachment string // 附件相对路径 FileMD5 string // 附件MD5 FileExt string // 文件扩展名 Width int // 图片宽 Height int // 图片高 // contains filtered or unexported fields }
Attachment 附件结构体,包含文件头信息、扩展名、保存目录和错误列表
func New ¶
func New(args ...interface{}) *Attachment
New 创建一个新的附件实例 args:
- GinContext *gin.Context Gin 上下文
- BaseConfig *jcbaseGo.AttachmentStruct 附件配置
- RemoteConfig interface{} 远程附件配置
func (*Attachment) SetBeforeSave ¶
func (a *Attachment) SetBeforeSave(fn func(a *Attachment) bool) *Attachment
SetBeforeSave 设置保存文件前的回调函数 - 回调函数返回 true 则继续保存,回调函数返回 false 则跳过
func (*Attachment) ToMedia ¶
func (a *Attachment) ToMedia(src string, args ...interface{}) string
Click to show internal directories.
Click to hide internal directories.