gofile

package
v1.2.36 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UPLOAD_TYPE_LOCAL = 1
	UPLOAD_TYPE_OSS   = 2
	UPLOAD_TYPE_CHUNK = 3
)
View Source
const (
	EL = "\n"
)

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src, dst string) error

复制文件

func CreateSavePath

func CreateSavePath(dst string, perm os.FileMode) error

func DIR

func DIR() string

目录名称

func Exist

func Exist(path string) (bool, error)

func FILE

func FILE() string

文件名

func GetFileHeaderMd5Name

func GetFileHeaderMd5Name(fileHeader *multipart.FileHeader) (string, error)

func GetFileList

func GetFileList(path string) []string

获取当前目录下所有文件

func LINE

func LINE() int

行号

func RemoveFile

func RemoveFile(file string) error

func SaveFile

func SaveFile(file *multipart.FileHeader, dst string) error

func Trace

func Trace(skip int) (arr []string)

追踪信息

func UploadChunk added in v1.2.34

func UploadChunk(url string, fileName string, fileMd5 string, chunkIndex int, chunkData []byte) (*gohttpx.Response, error)

上传一个文件分片

func WriteToFile

func WriteToFile(filename string, b []byte) error

写文件,支持路径创建

Types

type BigFile added in v1.2.34

type BigFile struct {
	ChunkSize         int64            // 分片大小 M
	MaxWorkers        int              // 同时处理最大分块数量,合理用防止超大文件内存益处
	File              string           // 文件路径
	FileMd5           string           // 文件Md5
	ChunkCount        int64            // 分片数量
	HandledChunkCount int64            // 已处理分片数量
	FileChunkCallback func(*FileChunk) // 分片处理消息
	// contains filtered or unexported fields
}

func (*BigFile) DoneOneChunk added in v1.2.34

func (b *BigFile) DoneOneChunk()

func (*BigFile) IsFinish added in v1.2.34

func (b *BigFile) IsFinish() bool

func (*BigFile) NextChunk added in v1.2.34

func (b *BigFile) NextChunk()

func (*BigFile) Release added in v1.2.34

func (b *BigFile) Release()

func (*BigFile) Start added in v1.2.34

func (b *BigFile) Start() error

func (*BigFile) Stop added in v1.2.34

func (b *BigFile) Stop()

func (*BigFile) WaitForFinish added in v1.2.34

func (b *BigFile) WaitForFinish()

type FileChunk added in v1.2.34

type FileChunk struct {
	Data          []byte //分片数据
	Hash          string //分片Hash
	Index         int64  //分片顺序号
	FileMd5       string //
	ChunkFileName string //
}

fmt.Sprintf("%s.part%d", fileName, i) mapreduce big file 大文件逻辑 for 把大文件并发分片处理,为了防止OOM超大文件边分片边处理的策略

type FileUploadResult

type FileUploadResult struct {
	OriginalFile string
	FileName     string
	ChunkCount   int64
}

func MergeFile added in v1.2.34

func MergeFile(filePath string, fileName string, fileMd5 string, totalChunks int64, isNotRemoveChunk bool) (*FileUploadResult, error)

服务器合并所有文件分片,并验证md5, isNotRemoveChunk =true 合并后时不会删除分片

func ReceiveChunkHandler added in v1.2.34

func ReceiveChunkHandler(assetsDir string, chunkIndex int64, chunkMd5 string, fileMd5 string, file *multipart.FileHeader) (*FileUploadResult, error)

服务器接受文件分片

func ReceiveFile added in v1.2.34

func ReceiveFile(assetsDir string, file *multipart.FileHeader) (*FileUploadResult, error)

服务器接受file文件到assetsDir目录下,assetsDir 目录不存在则自动创建,返回存储位置

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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