filedownloader

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 8 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileDownloader

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

FileDownloader ...

func New

func New(client HTTPClient) FileDownloader

New ...

func NewWithContext

func NewWithContext(context context.Context, client HTTPClient) FileDownloader

NewWithContext ...

func (FileDownloader) Get

func (downloader FileDownloader) Get(destination, source string) error

Get downloads a file from a given source. Provided destination should be a file that does not exist.

func (FileDownloader) GetRemoteContents

func (downloader FileDownloader) GetRemoteContents(URL string) ([]byte, error)

GetRemoteContents fetches a remote URL contents

func (FileDownloader) GetWithFallback

func (downloader FileDownloader) GetWithFallback(destination, source string, fallbackSources ...string) error

GetWithFallback downloads a file from a given source. Provided destination should be a file that does not exist. You can specify fallback sources which will be used in order if downloading fails from either source.

func (FileDownloader) ReadLocalFile

func (downloader FileDownloader) ReadLocalFile(path string) ([]byte, error)

ReadLocalFile returns a local file contents

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient ...

Jump to

Keyboard shortcuts

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