filedownloader

package
v2.0.0-alpha.39 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Downloader

type Downloader interface {
	// Download fetches a remote file and writes it to the specified destination path.
	Download(ctx context.Context, destination, source string) error

	// DownloadWithFallback tries to download from the primary source first,
	// then falls back to alternative sources in order if the primary fails.
	DownloadWithFallback(ctx context.Context, destination, source string, fallbackSources ...string) error

	// Get returns a streaming reader for the remote content without buffering the entire response in memory.
	// Caller is responsible for closing the returned io.ReadCloser.
	Get(ctx context.Context, source string) (io.ReadCloser, error)
}

Downloader provides methods for downloading files from remote URLs with automatic retries.

func NewDownloader

func NewDownloader(logger log.Logger) Downloader

NewDownloader creates a new Downloader with automatic retry support.

func NewDownloaderWithClient

func NewDownloaderWithClient(client *http.Client, logger log.Logger) Downloader

NewDownloaderWithClient creates a new Downloader with a custom HTTP client. Use this for advanced scenarios where you need custom client configuration. For most use cases, prefer NewDownloader which includes retry support by default.

Jump to

Keyboard shortcuts

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