Documentation ¶
Index ¶
- Variables
- func CleanDomain(fileURL string) string
- func EmbeddedRes(v string, fn func(string, int64)) [][]string
- func ExtensionRegexpEnd(noCaptures ...bool) string
- func ExtensionRegister(extensions ...string)
- func ExtensionUnregister(extensions ...string)
- func FileTypeByName(filename string) string
- func Init(pathPrefix string)
- func ParseDomain(fileURL string) (scheme string, domain string)
- func ParseSubdir(fileURL string) string
- func RelatedRes(v string, fn func(string, int64), seperator ...string)
- func ReplaceEmbeddedRes(v string, reses map[string]string) (r string)
- func ReplaceEmbeddedResID(v string, reses map[uint64]string) (r string)
- func ReplaceRelatedRes(v string, reses map[string]string, seperator ...string) (r string)
- func ReplaceRelatedResID(v string, reses map[uint64]string, seperator ...string) (r string)
- func URLToFile(fileURL string) string
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // UploadURLPath 上传文件网址访问路径 UploadURLPath = defaultUploadURLPath // UploadDir 定义上传目录(首尾必须带“/”) UploadDir = defaultUploadDir // AllowedUploadFileExtensions 被允许上传的文件的扩展名 AllowedUploadFileExtensions = []string{ `.jpeg`, `.jpg`, `.gif`, `.png`, } // FileTypeIcon 文件类型icon FileTypeIcon = upload.FileTypeIcon // DetectFileType 根据文件扩展名判断文件类型 DetectFileType = upload.DetectType // TypeRegister 注册文件扩展名 TypeRegister = upload.TypeRegister )
View Source
var ( ErrUnsupportedExtension = errors.New("不支持的文件扩展名") ErrIncorrectPath = errors.New("路径不合法") )
View Source
var IsRightUploadFile = func(ctx echo.Context, src string) error { src = path.Clean(src) ext := strings.ToLower(path.Ext(src)) if !com.InSlice(ext, AllowedUploadFileExtensions) { return errors.WithMessage(ErrIncorrectPath, ext) } if !strings.HasPrefix(src, UploadURLPath) { return ErrIncorrectPath } return nil }
IsRightUploadFile 是否是正确的上传文件
View Source
var ParseAnyFileName = func(s string) []string {
files := anyFileRegexp.FindAllString(s, -1)
return files
}
ParseAnyFileName 从文本中解析出任意上传文件名称
View Source
var ParsePersistentFileName = func(s string) []string {
files := persistentFileRegexp.FindAllString(s, -1)
return files
}
ParsePersistentFileName 从文本中解析出正式文件名称
View Source
var ParseTemporaryFileName = func(s string) []string {
files := temporaryFileRegexp.FindAllString(s, -1)
return files
}
ParseTemporaryFileName 从文本中解析出临时文件名称
View Source
var ReplaceAnyFileName = func(s string, repl func(string) string) string {
return anyFileRegexp.ReplaceAllStringFunc(s, repl)
}
ReplaceAnyFileName 从文本中替换任意上传文件名称
View Source
var ReplacePlaceholder = func(s string, repl func(string) string) string { return placeholderRegexp.ReplaceAllStringFunc(s, func(find string) string { id := find[9 : len(find)-1] return repl(id) }) }
ReplacePlaceholder 从文本中替换占位符
Functions ¶
func CleanDomain ¶
func EmbeddedRes ¶
EmbeddedRes 获取正文中的资源
func ExtensionRegexpEnd ¶
func ExtensionRegister ¶
func ExtensionRegister(extensions ...string)
func ExtensionUnregister ¶
func ExtensionUnregister(extensions ...string)
func ParseDomain ¶
func RelatedRes ¶
RelatedRes 获取字段中关联的资源
func ReplaceEmbeddedRes ¶
ReplaceEmbeddedRes 替换正文中的资源网址
func ReplaceEmbeddedResID ¶
ReplaceEmbeddedResID 替换正文中的资源网址
func ReplaceRelatedRes ¶
ReplaceRelatedRes 替换字段中的资源网址
func ReplaceRelatedResID ¶
ReplaceRelatedResID 替换字段中的资源网址
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.