uploader

package
v3.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoUpload

func DoUpload(uploadURL string, uploadReader io.Reader)

Types

type UploadStatus

type UploadStatus struct {
	Length   int64 // 总大小
	Uploaded int64 // 已上传数据
	Speed    int64 // 上传速度, 每秒
}

UploadStatus 上传状态

type Uploader

type Uploader struct {
	URL    string  // 上传地址
	Reader *reader // 要上传的对象
	// contains filtered or unexported fields
}

Uploader 上传

func NewUploader

func NewUploader(url string, uploadReader io.Reader, size int64, h *requester.HTTPClient) (uploader *Uploader)

NewUploader 返回 uploader 对象, url: 上传地址, uploadReader: 实现 io.Reader 接口的对象, 例如文件

func (*Uploader) Execute

func (u *Uploader) Execute(checkFunc func(respBodyContents []byte, err error))

Execute 执行上传

func (*Uploader) GetStatusChan

func (u *Uploader) GetStatusChan() <-chan UploadStatus

GetStatusChan 返回 UploadStatus 对象的 channel

func (*Uploader) OnExecute

func (u *Uploader) OnExecute(fn func())

OnExecute 任务开始时触发的事件

func (*Uploader) OnFinish

func (u *Uploader) OnFinish(fn func())

OnFinish 任务完成时触发的事件

Jump to

Keyboard shortcuts

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