download

package
v0.0.0-...-7c3525c Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSourceUrls                  = errors.New("source URLs required")
	ErrSourcesFileMismatch           = errors.New("file metadata from source URLs are not matching")
	ErrETagMismatch                  = errors.New("ETag mismatch")
	ErrUnknownContentLength          = errors.New("unknown content length")
	ErrPartialRequestUnsupported     = errors.New("partial request not supported")
	ErrFailedChunkDownloadAllSources = errors.New("failed to download chunk after attempting from all sources")
)

Functions

func GetMD5Hash

func GetMD5Hash(file *os.File) (string, error)

GetMD5Hash calculates the MD5 hash of the file contents and returns the hex encoding.

Types

type ETagCalculator

type ETagCalculator func(file *os.File) (string, error)

ETagCalculator represents a function that calculates the ETag of a file.

type Options

type Options struct {
	Connections  uint
	Timeout      uint
	CheckETag    bool
	Quiet        bool
	DestFilePath string
}

Options represents the configuration for the download service.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the service layer that contains operations for downloading.

func NewService

func NewService(opts Options, calculateETag ETagCalculator) *Service

func (*Service) Download

func (s *Service) Download(sourceUrls []string) error

Download attempts to download a file from the given sources in a concurrent manner (i.e., in chunks). This creates a temporary file while the download is ongoing and moves it to the actual configured destination file once the download is successfully completed.

Jump to

Keyboard shortcuts

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