uploader

package
v3.5.2+incompatible Latest Latest
Warning

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

Go to latest
Published: May 16, 2018 License: Apache-2.0 Imports: 7 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, readerlen64 rio.ReaderLen64, checkFunc CheckFunc)

DoUpload 执行上传

Types

type CheckFunc

type CheckFunc func(resp *http.Response, uploadErr error)

CheckFunc 上传完成的检测函数

type Readed64

type Readed64 interface {
	rio.ReaderLen64
	Readed() int64
}

Readed64 增加获取已读取数据量, 用于统计速度

func NewReaded64

func NewReaded64(rl rio.ReaderLen64) Readed64

NewReaded64 实现Readed64接口

type Status

type Status interface {
	TotalSize() int64           // 总大小
	Uploaded() int64            // 已上传数据
	SpeedsPerSecond() int64     // 每秒的上传速度
	TimeElapsed() time.Duration // 上传时间
}

Status 上传状态

type UploadStatus

type UploadStatus struct {
	// contains filtered or unexported fields
}

UploadStatus 上传状态

func (*UploadStatus) SpeedsPerSecond

func (us *UploadStatus) SpeedsPerSecond() int64

SpeedsPerSecond 返回每秒的上传速度

func (*UploadStatus) TimeElapsed

func (us *UploadStatus) TimeElapsed() time.Duration

TimeElapsed 返回上传时间

func (*UploadStatus) TotalSize

func (us *UploadStatus) TotalSize() int64

TotalSize 返回总大小

func (*UploadStatus) Uploaded

func (us *UploadStatus) Uploaded() int64

Uploaded 返回已上传数据

type Uploader

type Uploader struct {
	// contains filtered or unexported fields
}

Uploader 上传

func NewUploader

func NewUploader(url string, readedlen64 rio.ReaderLen64) (uploader *Uploader)

NewUploader 返回 uploader 对象, url: 上传地址, readerlen64: 实现 rio.ReaderLen64 接口的对象, 例如文件

func (*Uploader) Execute

func (u *Uploader) Execute()

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

func (*Uploader) GetStatusChan

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

GetStatusChan 获取上传状态

func (*Uploader) OnExecute

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

OnExecute 任务开始时触发的事件

func (*Uploader) OnFinish

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

OnFinish 任务完成时触发的事件

func (*Uploader) SetCheckFunc

func (u *Uploader) SetCheckFunc(checkFunc CheckFunc)

SetCheckFunc 设置上传完成的检测函数

func (*Uploader) SetClient

func (u *Uploader) SetClient(c *requester.HTTPClient)

SetClient 设置http客户端

func (*Uploader) SetContentType

func (u *Uploader) SetContentType(contentType string)

SetContentType 设置Content-Type

Jump to

Keyboard shortcuts

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