// 文件为大小文件的依据是ParseMultipartForm的maxMemory参数的大小
// 获取文件大小的接口,上传小文件时,文件类型为:multipart.sectionReadCloser
type Size interface {Size() int64
}// 获取文件信息的接口,上传大文件时,文件类型为: *os.File
type Stat interface {Stat() (os.FileInfo, error)
}icon, _, err := req.FormFile("icon")if statInterface, ok := icon.(Stat); ok {fileInfo, err := statInterface.Stat()if err == nil {if fileInfo.Size() > (maxIconSize) {code = errParseFileFailedmsg = fmt.Sprint("上传文件不要超过", maxIconSize>>20, "M")return}} else if sizeInterface, ok := icon.(Size); ok {if sizeInterface.Size() > (maxIconSize) {code = errParseFileFailedmsg = fmt.Sprint("上传文件不要超过", maxIconSize>>20, "M")return}}}if err != nil {code = errParseFileFailedmsg = err.Error()return}defer icon.Close()