download

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: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrivateUrl

func PrivateUrl(info UrlApiInfo) (fileUrl string)

PrivateUrl 返回私有空间的下载链接, 也可以用于公有空间的下载

func PublicUrl

func PublicUrl(info UrlApiInfo) (fileUrl string)

PublicUrl 返回公有空间的下载链接,不可以用于私有空间的下载

func PublicUrlToPrivate

func PublicUrlToPrivate(info PublicUrlToPrivateApiInfo) (finalUrl string, err *data.CodeError)

PublicUrlToPrivate 公转私

Types

type ApiInfo

type ApiInfo struct {
	Bucket               string            // 文件所在 bucket 【必填】
	Key                  string            // 文件被保存的 key 【必填】
	IsPublic             bool              // 是否使用共有链接 【必填】
	HostProvider         host.Provider     // 文件下载的 host, domain 可能为 ip, 需要搭配 host 使用 【选填】
	ToFile               string            // 文件保存的路径 【必填】
	StatusDBPath         string            // 下载状态缓存的 db 路径 【选填】
	Referer              string            // 请求 header 中的 Referer 【选填】
	FileEncoding         string            // 文件编码方式 【选填】
	FileModifyTime       int64             // 文件修改时间 【选填】
	FileSize             int64             // 文件大小,有值则会检测文件大小 【选填】
	FileHash             string            // 文件 hash,有值则会检测 hash 【选填】
	FromBytes            int64             // 下载开始的位置,内部会缓存 【内部使用】
	RemoveTempWhileError bool              // 当遇到错误时删除临时文件 【选填】
	UseGetFileApi        bool              // 是否使用 get file api(私有云会使用)【选填】
	Progress             progress.Progress // 下载进度回调【选填】
}

func (*ApiInfo) WorkId

func (i *ApiInfo) WorkId() string

type ApiResult

type ApiResult struct {
	FileAbsPath string // 文件被保存的绝对路径
	IsUpdate    bool   // 是否为接续下载
	IsExist     bool   // 是否为已存在
}

func Download

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

Download 下载一个文件,从 Url 下载保存至 ToFile

type LocalFileInfo

type LocalFileInfo struct {
	File                string // 被检测的文件 【必填】
	Bucket              string // 文件所在 bucket 用于检查 hash【选填】
	Key                 string // 文件被保存的 key  用于检查 hash【选填】
	FileHash            string // 文件 hash,有值则会检测 hash【选填】
	FileSize            int64  // 文件大小,有值则会检测文件大小【选填】
	RemoveFileWhenError bool   // 当遇到错误时是否该移除文件【选填】
}

func (*LocalFileInfo) CheckDownloadFile

func (l *LocalFileInfo) CheckDownloadFile() (err *data.CodeError)

func (*LocalFileInfo) CheckFileHashOfDownloadFile

func (l *LocalFileInfo) CheckFileHashOfDownloadFile() *data.CodeError

func (*LocalFileInfo) CheckFileSizeOfDownloadFile

func (l *LocalFileInfo) CheckFileSizeOfDownloadFile() *data.CodeError

type PublicUrlToPrivateApiInfo

type PublicUrlToPrivateApiInfo struct {
	PublicUrl string
	Deadline  int64
}

PublicUrlToPrivateApiInfo 私有下载链接

type UrlApiInfo

type UrlApiInfo struct {
	BucketDomain string
	Key          string
	UseHttps     bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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