uploader

package
v3.2.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoUpload

func DoUpload(uploadURL string, isMultipart bool, uploadReaderLen ReaderLen, checkFunc func(resp *http.Response, err error))

DoUpload 执行上传

Types

type ReaderLen

type ReaderLen interface {
	io.Reader
	Len() int64
}

ReaderLen 实现 读 和 长度 接口

func NewFileReaderLen

func NewFileReaderLen(f *os.File) ReaderLen

NewFileReaderLen 将 *os.File 文件对象实现 ReaderLen 接口

type UploadStatus

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

UploadStatus 上传状态

type Uploader

type Uploader struct {
	URL         string // 上传地址
	IsMultiPart bool   // 是否表单上传

	Body *reader // 要上传的对象
	// contains filtered or unexported fields
}

Uploader 上传

func NewUploader

func NewUploader(url string, isMultipart bool, uploadReaderLen ReaderLen, h *requester.HTTPClient) (uploader *Uploader)

NewUploader 返回 uploader 对象, url: 上传地址, isMultipart: 是否表单上传,uploadReaderLen: 实现 uploader.ReaderLen 接口的对象, 例如文件

func (*Uploader) Execute

func (u *Uploader) Execute(checkFunc func(resp *http.Response, 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