Documentation
¶
Index ¶
Constants ¶
View Source
const ( // MaxUploadSize 默认最大上传资源大小是10M MaxUploadSize = 10 << 20 // 使用位运算更清晰 )
Variables ¶
View Source
var ( // GroupMimeTypes 类型分组 GroupMimeTypes = map[int][]string{ 1: {"image/jpeg", "image/png", "image/gif", "image/bmp", "image/svg", "image/jpg"}, 2: {"video/mp4", "video/vnd.rn-realmedia-vbr", "video/x-msvideo"}, 3: { "application/pdf", "application/msword", "application/vnd.ms-excel", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.presentationml.presentation", }, } // AllowTypes 默认允许上传的文件类型 AllowTypes = map[string]string{ "jpg": "image/jpg", "jpeg": "image/jpeg", "png": "image/png", "svg": "image/svg", "gif": "image/gif", "bmp": "image/bmp", "webp": "image/webp", "mp3": "audio/mpeg", "mp4": "video/mp4", "avi": "video/x-msvideo", "rmvb": "video/vnd.rn-realmedia-vbr", "pdf": "application/pdf", "xls": "application/vnd.ms-excel", "xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "ppt": "application/vnd.ms-powerpoint", "doc": "application/msword", "docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation", } )
Functions ¶
func ParseXOssProcess ¶
ParseXOssProcess 解析x-oss-process参数 示例: image/resize,m_lfit,h_200,w_200
func ProcessImageWithXOssProcess ¶
ProcessImageWithXOssProcess 根据x-oss-process参数处理图片 aliyun oss doc: https://help.aliyun.com/document_detail/44688.html
Types ¶
type File ¶
type File struct {
FileName *multipart.FileHeader `form:"file"`
}
type FileHeader ¶
type FileHeader struct {
AttachmentId uint64 `json:"attachment_id"`
Filename string `json:"file_name"` // 图片新名称
FileSize int64 `json:"file_size"` // 图片大小
FilePath string `json:"file_path"` // 相对路径地址
OriginName string `json:"origin_name"` // 图片原名称
MimeType string `json:"mime_type"` // 附件mime类型
Extension string `json:"extension"` // 附件后缀名
}
FileHeader 文件参数
type Upload ¶
type Upload struct {
// contains filtered or unexported fields
}
func (*Upload) GetFileInfo ¶
GetFileInfo 根据不同的上传类型获取文信息
func (*Upload) Upload ¶
func (u *Upload) Upload(file *multipart.FileHeader, path string) (*FileHeader, error)
Upload 根据配置的上传类型选择上传方式
Click to show internal directories.
Click to hide internal directories.