download

package
v2.11.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: MIT Imports: 26 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 DownloadActionInfo added in v2.10.0

type DownloadActionInfo 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 【选填】
	DownloadFileSize       int64             `json:"download_file_size"`   // 下载的文件大小,下载整个文件时,等于 ServerFileSize;切片下载则为切片大小;有值则会检测文件大小【选填】
	CheckSize              bool              `json:"-"`                    // 是否检测文件大小 【选填】
	CheckHash              bool              `json:"-"`                    // 是否检测文件 hash 【选填】
	FromBytes              int64             `json:"-"`                    // 下载开始的位置,内部会缓存 【内部使用】
	ToBytes                int64             `json:"-"`                    // 下载的终止位置【内部使用】
	RemoveTempWhileError   bool              `json:"-"`                    // 当遇到错误时删除临时文件 【选填】
	UseGetFileApi          bool              `json:"-"`                    // 是否使用 get file api(私有云会使用)【选填】
	EnableSlice            bool              `json:"-"`                    // 大文件允许切片下载 【选填】
	SliceFileSizeThreshold int64             `json:"-"`                    // 允许切片下载,切片下载出发的文件大小阈值 【选填】
	SliceSize              int64             `json:"-"`                    // 允许切片下载,切片的大小 【选填】
	SliceConcurrentCount   int               `json:"-"`                    // 允许切片下载,并发下载切片的个数 【选填】
	Progress               progress.Progress `json:"-"`                    // 下载进度回调【选填】
}

func (*DownloadActionInfo) WorkId added in v2.10.0

func (i *DownloadActionInfo) WorkId() string

type DownloadActionResult added in v2.10.0

type DownloadActionResult struct {
	FileModifyTime int64  `json:"file_modify_time"` // 下载后文件修改时间
	FileAbsPath    string `json:"file_abs_path"`    // 文件被保存的绝对路径
	IsUpdate       bool   `json:"is_update"`        // 是否为接续下载
	IsExist        bool   `json:"is_exist"`         // 是否为已存在
}

func Download

func Download(info *DownloadActionInfo) (res *DownloadActionResult, err *data.CodeError)

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

func (*DownloadActionResult) IsValid added in v2.10.0

func (a *DownloadActionResult) IsValid() bool

type DownloadApiInfo added in v2.10.0

type DownloadApiInfo struct {
	Url            string
	Host           string
	Referer        string
	RangeFromBytes int64
	RangeToBytes   int64
	CheckSize      bool
	FileSize       int64
	CheckHash      bool
	FileHash       string
	Progress       progress.Progress
}

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