downloader

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Downloader

type Downloader interface {
	Get(ctx context.Context, url string, header *http.Header) (*WebAsset, *http.Response, error)
}

Downloader is a service used to download assets.

func NewDefaultDownloader

func NewDefaultDownloader(downloadCache cache.Cache) Downloader

NewDefaultDownloader create new downloader with defaults

func NewInternalDownloader

func NewInternalDownloader(client *http.Client, downloadCache cache.Cache, maxConcurrentDownload int64) Downloader

NewInternalDownloader create new downloader instance

type InternalDownloader

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

InternalDownloader interface

func (*InternalDownloader) Get added in v1.2.0

func (dl *InternalDownloader) Get(ctx context.Context, url string, header *http.Header) (*WebAsset, *http.Response, error)

Download web asset from its URL

type WebAsset

type WebAsset struct {
	Data        []byte
	ContentType string
	Name        string
}

WebAsset is a structure used to store file properties.

func NewWebAsset

func NewWebAsset(b []byte) (*WebAsset, error)

NewWebAsset byte array to file asset sctructure

func (*WebAsset) Encode

func (wa *WebAsset) Encode() ([]byte, error)

Encode file asset structure to byte array

func (*WebAsset) ToDataURL

func (obj *WebAsset) ToDataURL() string

ToDataURL returns base64 encoded data URL of the file asset

func (*WebAsset) Write added in v1.2.0

func (wa *WebAsset) Write(w http.ResponseWriter, header http.Header) (int, error)

Write to HTTP writer

Jump to

Keyboard shortcuts

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