upload

package
v2.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 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            `json:"file_path"`              // 文件路径,可为网络资源,也可为本地资源
	ToBucket            string            `json:"to_bucket"`              // 文件保存至 bucket 的名称
	SaveKey             string            `json:"save_key"`               // 文件保存的名称
	MimeType            string            `json:"mime_type"`              // 文件类型
	FileType            int               `json:"file_type"`              // 存储状态
	CheckExist          bool              `json:"-"`                      // 检查服务端是否已存在此文件
	CheckHash           bool              `json:"-"`                      // 是否检查 hash, 检查是会对比服务端文件 hash
	CheckSize           bool              `json:"-"`                      // 是否检查文件大小,检查是会对比服务端文件大小
	Overwrite           bool              `json:"-"`                      // 当遇到服务端文件已存在时,是否使用本地文件覆盖之服务端的文件
	UpHost              string            `json:"up_host"`                // 上传使用的域名
	TokenProvider       func() string     `json:"-"`                      // token provider
	TryTimes            int               `json:"-"`                      // 失败时,最多重试次数【可选】
	TryInterval         time.Duration     `json:"-"`                      // 重试间隔时间 【可选】
	LocalFileSize       int64             `json:"local_file_size"`        // 待上传文件的大小, 如果不配置会动态读取 【可选】
	LocalFileModifyTime int64             `json:"local_file_modify_time"` // 待上传文件修改时间, 如果不配置会动态读取 【可选】
	DisableForm         bool              `json:"-"`                      // 不使用 form 上传 【可选】
	DisableResume       bool              `json:"-"`                      // 不使用分片上传 【可选】
	UseResumeV2         bool              `json:"-"`                      // 分片上传时是否使用分片 v2 上传 【可选】
	ResumeWorkerCount   int               `json:"-"`                      // 分片上传 worker 数量
	ChunkSize           int64             `json:"-"`                      // 分片上传时的分片大小
	PutThreshold        int64             `json:"-"`                      // 分片上传时上传阈值
	CacheDir            string            `json:"-"`                      // 临时数据保存路径
	SequentialReadFile  bool              `json:"-"`                      // 文件是否使用顺序读
	Progress            progress.Progress `json:"-"`                      // 上传进度回调
}

func (*ApiInfo) Check

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

func (*ApiInfo) WorkId added in v2.9.0

func (a *ApiInfo) WorkId() string

type ApiResult

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

func Upload

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

func (*ApiResult) IsValid added in v2.8.0

func (a *ApiResult) IsValid() bool

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