downloader

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: AGPL-3.0 Imports: 14 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 {
	Download(ctx context.Context, url string) (*WebAsset, 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) Download

func (dl *InternalDownloader) Download(ctx context.Context, url string) (*WebAsset, 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 (obj 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

Jump to

Keyboard shortcuts

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