upload

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApiResultFormat

func ApiResultFormat() string

func ProgressFileFromUrl

func ProgressFileFromUrl(srcResUrl, bucket, key string) (progressFile string, err *data.CodeError)

Types

type ApiInfo

type ApiInfo struct {
	FilePath          string            // 文件路径,可为网络资源,也可为本地资源
	ToBucket          string            // 文件保存至 bucket 的名称
	SaveKey           string            // 文件保存的名称
	MimeType          string            // 文件类型
	FileType          int               // 存储状态
	CheckExist        bool              // 检查服务端是否已存在此文件
	CheckHash         bool              // 是否检查 hash, 检查是会对比服务端文件 hash
	CheckSize         bool              // 是否检查文件大小,检查是会对比服务端文件大小
	Overwrite         bool              // 当遇到服务端文件已存在时,是否使用本地文件覆盖之服务端的文件
	UpHost            string            // 上传使用的域名
	FileStatusDBPath  string            // 文件上传状态信息保存的 db 路径
	TokenProvider     func() string     // token provider
	TryTimes          int               // 失败时,最多重试次数【可选】
	TryInterval       time.Duration     // 重试间隔时间 【可选】
	FileSize          int64             // 待上传文件的大小, 如果不配置会动态读取 【可选】
	FileModifyTime    int64             // 本地文件修改时间, 如果不配置会动态读取 【可选】
	DisableForm       bool              // 不使用 form 上传 【可选】
	DisableResume     bool              // 不使用分片上传 【可选】
	UseResumeV2       bool              // 分片上传时是否使用分片 v2 上传 【可选】
	ResumeWorkerCount int               // 分片上传 worker 数量
	ChunkSize         int64             // 分片上传时的分片大小
	PutThreshold      int64             // 分片上传时上传阈值
	Progress          progress.Progress // 上传进度回调
}

func (*ApiInfo) Check

func (a *ApiInfo) Check() (err *data.CodeError)

type ApiResult

type ApiResult struct {
	Key            string `json:"key"`
	MimeType       string `json:"mime_type"` // 文件类型
	FSize          int64  `json:"file_size"` // 文件大小
	Hash           string `json:"hash"`      // 文件 etag
	IsSkip         bool   `json:"-"`         // 是否被 skip
	IsNotOverwrite bool   `json:"-"`         // 是否因未开启 overwrite 而未覆盖之前的上传
	IsOverwrite    bool   `json:"-"`         // 覆盖之前的上传
}

func Upload

func Upload(info *ApiInfo) (res ApiResult, err *data.CodeError)

type Uploader

type Uploader interface {
	// contains filtered or unexported methods
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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