ifile

package
v1.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2024 License: Apache-2.0 Imports: 24 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirSeparator

func DirSeparator() string

DirSeparator 路径分割符

func FilenameMd5

func FilenameMd5(content string) string

FilenameMd5 Md5文件名

func GenFilename

func GenFilename(fileExt string, names ...string) string

GenFilename 生成文件名

func IsDriveLetterRoot

func IsDriveLetterRoot(path string) bool

IsDriveLetterRoot 验证是系统根目录

func IsWindowsPath

func IsWindowsPath(path string) bool

IsWindowsPath 检查路径字符串是否使用Windows风格的路径分隔符

func MustResourcePath

func MustResourcePath(paths ...string) string

MustResourcePath 获取资源静态目录-绝对

func MustRootPath

func MustRootPath() string

MustRootPath 获取当前项目根目录

func MustUploadPath

func MustUploadPath(paths ...string) string

MustUploadPath 获取并设置上传目录

func NormalizePath

func NormalizePath(path string) string

NormalizePath 规格化路径

func ParseBase64ImageExt

func ParseBase64ImageExt(baseExt string, filename ...string) (string, error)

解析Base64前缀获取图片扩展

func ReadContent

func ReadContent(fs *os.File) ([]byte, error)

ReadContent 读取文件内容

func ReadHasher

func ReadHasher(fs *os.File) (string, error)

ReadHasher 读取Hash值内容

func ReadImageWH

func ReadImageWH(fs *os.File) (w, h int, err error)

ReadImageWH 读取图片文件高宽度

func RelaResourcePath

func RelaResourcePath(paths ...string) string

RelaResourcePath 相对资源静态目录

func RelaUploadPath

func RelaUploadPath(paths ...string) string

RelaUploadPath 相对设置上传目录

func RootPath

func RootPath() (string, error)

RootPath 获取当前项目根目录

func SlashUploadPath

func SlashUploadPath(path string, pfs ...string) string

SlashUploadPath 从给定路径中提取指定Linux风格路径部分(统一转换为Linux路径地址)

func SuppIndicator

func SuppIndicator(path string) string

SuppIndicator 补充相对路径指示符(.)

func UploadSubDir

func UploadSubDir(dir string, isRoot bool) string

UploadSubDir 设置上传附件路径

Types

type FileAttract

type FileAttract struct {
	Path string
	Ctx  context.Context
}

FileAttract 文件属性

func New

func New(path string) *FileAttract

New 实例

func (*FileAttract) Attract

func (a *FileAttract) Attract() (*FileInfo, error)

Attract 获取文件详情属性

func (*FileAttract) Content

func (a *FileAttract) Content() ([]byte, error)

Content 读取文件二进制内容

func (*FileAttract) Hasher

func (a *FileAttract) Hasher() (string, error)

Hasher 读取文件Hash值

func (FileAttract) ImageWH

func (a FileAttract) ImageWH() (w, h int, err error)

ImageWH 打开图片文件获取宽度和高度

func (*FileAttract) MustContentBase64String

func (a *FileAttract) MustContentBase64String() string

MustContentBase64String 读取文件内容转换Base64字符

func (*FileAttract) MustContentString

func (a *FileAttract) MustContentString() string

MustContentString 读取文件内容转字符串

func (*FileAttract) MustHasherString

func (a *FileAttract) MustHasherString() string

MustHasherString 必须创建获取Hash值

func (*FileAttract) Open

func (a *FileAttract) Open() (*os.File, error)

Open 打开文件内容

type FileInfo

type FileInfo struct {
	Size   int64  // 内存大小
	Width  int    // 宽度
	Height int    // 高度
	Name   string // 文件名
	Hash   string // hash值
}

FileInfo 文件详情

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL