Documentation ¶
Index ¶
- Constants
- func CopyFile(from, to string) error
- func Hash(filePath string) (string, int64, error)
- func HashFromFile(f io.Reader) (string, int64, error)
- func HashIdentifier(filePath string) (string, int64, error)
- func HashIdentifierFromFile(f io.Reader) (string, int64, error)
- func Identifier(hash string, size int64) string
- func Md5(filePath string) (string, int64, error)
- func Md5FromFile(f io.Reader) (string, int64, error)
- func MoveFileToDir(filePath, fileDir string) (targetPath string, err error)
- func Sha256(filePath string) (string, int64, error)
- func Sha256FromFile(f io.Reader) (string, int64, error)
Constants ¶
View Source
const ( DefaultFileMode os.FileMode = 0744 // 文件权限 DefaultRuntimeDir = "runtime" // 临时目录 DefaultMaxSize = 20 << 20 // 20M )
Variables ¶
This section is empty.
Functions ¶
func HashIdentifier ¶
HashIdentifier 文件标识符; return identifier, size, err identifier = hash + "-" + size;
func HashIdentifierFromFile ¶
HashIdentifierFromFile 文件标识符; return identifier, size, err identifier = hash + "-" + size
func Identifier ¶
Identifier return hash + "-" + size md5(32)+size(19)=51; sha256(64)碰撞概率非常低 可结合mime类型来提高可靠性,mime读取可参考: https://github.com/h2non/filetype; pass the file header = first 261 bytes
func Md5FromFile ¶
Md5FromFile return md5, size, err
func MoveFileToDir ¶
MoveFileToDir 移动文件到目录
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.