downloader

package
v0.3.14 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultMinSize = 5 * 1024 * 1024 // object bigger than this will be downloaded parallely
)

Functions

This section is empty.

Types

type Downloader

type Downloader struct {
	Client         *http.Client
	MaxConcurrency int // 最大并发
	SizeThreshold  int // 触发并发的最小大小, default 5MB
}

Downloader 文件下载器

func (*Downloader) FileSize

func (dl *Downloader) FileSize(ctx context.Context, url string) (int, error)

head 获取要下载的文件的基本信息(header) 使用HTTP Method Head

func (*Downloader) Multi

func (dl *Downloader) Multi(ctx context.Context, url string) (*bytes.Buffer, error)

func (*Downloader) Single

func (dl *Downloader) Single(ctx context.Context, url string) (*bytes.Buffer, error)

type Partial

type Partial struct {
	Client     *http.Client
	Url        string
	Start, End int
	// contains filtered or unexported fields
}

filePart 文件分片

func (*Partial) Data

func (dl *Partial) Data() []byte

func (*Partial) Download

func (dl *Partial) Download(ctx context.Context) error

下载分片

Jump to

Keyboard shortcuts

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