fileutil

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MD5    = "md5"
	SHA1   = "sha1"
	SHA256 = "sha256"
	SHA512 = "sha512"
)

Variables

This section is empty.

Functions

func HashBytes

func HashBytes(data []byte, alg string) (string, error)

针对 []byte 流式哈希。alg为"md5"|"sha1"|"sha256"|"sha512"

func HashFile

func HashFile(path string, alg string) (string, error)

针对 文件 流式哈希。alg为"md5"|"sha1"|"sha256"|"sha512"

func HashReader

func HashReader(r io.Reader, alg string) (string, error)

流式哈希,alg为"md5"|"sha1"|"sha256"|"sha512"

func SaveFile

func SaveFile(fileHeader *multipart.FileHeader, dstPath, fileType, expectedHash string) error

SaveFile 保存上传的文件 增加了严格的安全校验 参数: fileHeader *multipart.FileHeader: 上传的文件 dstPath string: 文件保存的目标路径 fileType: 文件类型, 如 "application/zip",可以为空,表示不进行文件类型校验 expectedHash string: 预期的文件的哈希值,用于严格校验,为空表示不进行校验

Types

This section is empty.

Jump to

Keyboard shortcuts

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