uploader

package
v3.3.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package uploader 上传包

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoUpload

func DoUpload(uploadURL string, readedlen64 multipartreader.ReadedLen64, o *Options, checkFunc func(resp *http.Response, err error))

DoUpload 执行上传

Types

type Options

type Options struct {
	IsMultiPart bool                  // 是否表单上传
	Client      *requester.HTTPClient // http 客户端
}

Options are the options for creating a new Uploader

type UploadStatus

type UploadStatus struct {
	Length      int64         // 总大小
	Uploaded    int64         // 已上传数据
	Speed       int64         // 上传速度, 每秒
	TimeElapsed time.Duration // 上传时间
}

UploadStatus 上传状态

type Uploader

type Uploader struct {
	URL  string                      // 上传地址
	Body multipartreader.ReadedLen64 // 要上传的对象

	Options *Options

	UploadStatus <-chan UploadStatus // 上传状态
	// contains filtered or unexported fields
}

Uploader 上传

func NewUploader

func NewUploader(url string, readedlen64 multipartreader.ReadedLen64, o *Options) (uploader *Uploader)

NewUploader 返回 uploader 对象, url: 上传地址, readedlen64: 实现 multipartreader.ReadedLen64 接口的对象, 例如文件

func (*Uploader) Execute

func (u *Uploader) Execute(checkFunc func(resp *http.Response, err error)) <-chan struct{}

Execute 执行上传, 收到返回值信号则为上传结束

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