download

package
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 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 返回公有空间的下载链接,不可以用于私有空间的下载

Types

type ApiInfo

type ApiInfo struct {
	Bucket               string            `json:"bucket"`               // 文件所在 bucket 【必填】
	Key                  string            `json:"key"`                  // 文件被保存的 key 【必填】
	IsPublic             bool              `json:"-"`                    // 是否使用共有链接 【必填】
	HostProvider         host.Provider     `json:"-"`                    // 文件下载的 host, domain 可能为 ip, 需要搭配 host 使用 【选填】
	DestDir              string            `json:"-"`                    // 文件存储目标路径,目前是为了方便用户在批量下载时构建 ToFile 【此处选填】
	ToFile               string            `json:"to_file"`              // 文件保存的路径 【必填】
	Referer              string            `json:"referer"`              // 请求 header 中的 Referer 【选填】
	FileEncoding         string            `json:"-"`                    // 文件编码方式 【选填】
	ServerFilePutTime    int64             `json:"server_file_put_time"` // 文件修改时间 【选填】
	ServerFileSize       int64             `json:"server_file_size"`     // 文件大小,有值则会检测文件大小 【选填】
	ServerFileHash       string            `json:"server_file_hash"`     // 文件 hash,有值则会检测 hash 【选填】
	FromBytes            int64             `json:"-"`                    // 下载开始的位置,内部会缓存 【内部使用】
	RemoveTempWhileError bool              `json:"-"`                    // 当遇到错误时删除临时文件 【选填】
	UseGetFileApi        bool              `json:"-"`                    // 是否使用 get file api(私有云会使用)【选填】
	Progress             progress.Progress `json:"-"`                    // 下载进度回调【选填】
}

func (*ApiInfo) WorkId

func (i *ApiInfo) WorkId() string

type ApiResult

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

func Download

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

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

func (*ApiResult) IsValid added in v2.8.0

func (a *ApiResult) IsValid() bool

type PublicUrlToPrivateApiInfo

type PublicUrlToPrivateApiInfo struct {
	PublicUrl string
	Deadline  int64
}

PublicUrlToPrivateApiInfo 私有下载链接

type PublicUrlToPrivateApiResult added in v2.8.0

type PublicUrlToPrivateApiResult struct {
	Url string
}

func PublicUrlToPrivate

func PublicUrlToPrivate(info PublicUrlToPrivateApiInfo) (result *PublicUrlToPrivateApiResult, err *data.CodeError)

PublicUrlToPrivate 公转私

func (*PublicUrlToPrivateApiResult) IsValid added in v2.8.0

func (p *PublicUrlToPrivateApiResult) IsValid() bool

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