file

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Downloader

type Downloader struct {
	FileSize         int
	Link             string
	FilePath         string
	TotalPart        int //下载线程
	DoneFilePart     []Part
	PartSize         int
	PartCoroutineNum int //分片下载协程数
}

FileDownloader 文件下载器

func NewFileDownloader

func NewFileDownloader(downloadLink, filePath string) *Downloader

NewFileDownloader .

func (*Downloader) Download

func (d *Downloader) Download(partFilePath string, backCall func(fileTotalSize int, fileName string, Index int)) error

Run 开始下载任务

func (*Downloader) SetCoroutineNum

func (d *Downloader) SetCoroutineNum(partCoroutineNum int)

func (*Downloader) SetPartSize

func (d *Downloader) SetPartSize(partSize int)

func (*Downloader) SetTotalPart

func (d *Downloader) SetTotalPart(totalPart int)

type Part

type Part struct {
	Index    int    //文件分片的序号
	From     int    //开始byte
	To       int    //解决byte
	Data     []byte //http下载得到的文件内容
	FilePath string //下载到本地的分片文件路径
}

filePart 文件分片

type Uploader

type Uploader struct {
	Url      string
	FilePath string
}

func NewFileUploader

func NewFileUploader(url, filePath string) *Uploader

NewFileUploader

func (*Uploader) Upload

func (u *Uploader) Upload() ([]byte, error)

上传文件

func (*Uploader) UploadByByte

func (u *Uploader) UploadByByte(fileByte []byte) ([]byte, error)

直接通过字节上传

Jump to

Keyboard shortcuts

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