request

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: GPL-3.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(ctx context.Context, r Downloader, key string, fn string) error

func DownloadAll added in v1.0.0

func DownloadAll(ctx context.Context, r Store, outDir string, prefix string, checkFile func(string) bool) ([]string, error)

func Upload added in v1.0.0

func Upload(ctx context.Context, r Uploader, fn string, key string) error

func UploadAll added in v1.0.0

func UploadAll(ctx context.Context, r Uploader, srcDir string, prefix string, checkFile func(string) bool) error

func WithAllowFTP

func WithAllowFTP(req *Request)

func WithAllowLocal

func WithAllowLocal(req *Request)

func WithAllowS3

func WithAllowS3(req *Request)

func WithAuth

func WithAuth(secret dmfr.Secret, auth dmfr.FeedAuthorization) func(req *Request)

Types

type Az

type Az struct {
	Account   string
	Container string
	KeyPrefix string
}

func NewAzFromUrl

func NewAzFromUrl(ustr string) (*Az, error)

func (Az) CreateSignedUrl

func (r Az) CreateSignedUrl(ctx context.Context, key string, contentDisposition string) (string, error)

func (Az) Download

func (r Az) Download(ctx context.Context, key string) (io.ReadCloser, int, error)

func (Az) DownloadAuth added in v1.0.0

func (r Az) DownloadAuth(ctx context.Context, key string, auth dmfr.FeedAuthorization) (io.ReadCloser, int, error)

func (Az) ListKeys added in v1.0.0

func (r Az) ListKeys(ctx context.Context, prefix string) ([]string, error)

func (*Az) SetSecret added in v1.0.0

func (r *Az) SetSecret(secret dmfr.Secret) error

func (Az) Upload

func (r Az) Upload(ctx context.Context, key string, uploadFile io.Reader) error

type CanSetSecret added in v1.0.0

type CanSetSecret interface {
	SetSecret(dmfr.Secret) error
}

type Downloader

type Downloader interface {
	Download(context.Context, string) (io.ReadCloser, int, error)
	DownloadAuth(context.Context, string, dmfr.FeedAuthorization) (io.ReadCloser, int, error)
}

type FetchResponse

type FetchResponse struct {
	ResponseSize   int
	ResponseCode   int
	ResponseTimeMs int
	ResponseTtfbMs int
	ResponseSHA1   string
	FetchError     error
}

func AuthenticatedRequest

func AuthenticatedRequest(ctx context.Context, out io.Writer, address string, opts ...RequestOption) (FetchResponse, error)

AuthenticatedRequestContext fetches a url using a secret and auth description.

func AuthenticatedRequestDownload

func AuthenticatedRequestDownload(ctx context.Context, address string, opts ...RequestOption) (string, FetchResponse, error)

AuthenticatedRequestDownload is similar to AuthenticatedRequest but writes to a temporary file. Fatal errors will be returned as the error; non-fatal errors as FetchResponse.FetchError

type Ftp

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

func (Ftp) Download

func (r Ftp) Download(ctx context.Context, ustr string) (io.ReadCloser, int, error)

func (Ftp) DownloadAuth added in v1.0.0

func (r Ftp) DownloadAuth(ctx context.Context, ustr string, auth dmfr.FeedAuthorization) (io.ReadCloser, int, error)

func (*Ftp) SetSecret added in v1.0.0

func (r *Ftp) SetSecret(secret dmfr.Secret) error

type Http

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

func (Http) Download

func (r Http) Download(ctx context.Context, ustr string) (io.ReadCloser, int, error)

func (Http) DownloadAuth added in v1.0.0

func (r Http) DownloadAuth(ctx context.Context, ustr string, auth dmfr.FeedAuthorization) (io.ReadCloser, int, error)

func (*Http) SetSecret added in v1.0.0

func (r *Http) SetSecret(secret dmfr.Secret) error

type Local

type Local struct {
	Directory string
}

func (Local) Download

func (r Local) Download(ctx context.Context, key string) (io.ReadCloser, int, error)

func (Local) DownloadAuth added in v1.0.0

func (r Local) DownloadAuth(ctx context.Context, key string, auth dmfr.FeedAuthorization) (io.ReadCloser, int, error)

func (Local) Exists

func (r Local) Exists(ctx context.Context, key string) bool

func (*Local) ListKeys added in v1.0.0

func (r *Local) ListKeys(ctx context.Context, prefix string) ([]string, error)

func (*Local) SetSecret added in v1.0.0

func (r *Local) SetSecret(secret dmfr.Secret) error

func (Local) Upload

func (r Local) Upload(ctx context.Context, key string, uploadFile io.Reader) error

type Presigner

type Presigner interface {
	CreateSignedUrl(context.Context, string, string) (string, error)
}

type Request

type Request struct {
	URL        string
	AllowFTP   bool
	AllowLocal bool
	AllowS3    bool
	MaxSize    uint64
	Secret     dmfr.Secret
	Auth       dmfr.FeedAuthorization
}

func NewRequest

func NewRequest(address string, opts ...RequestOption) *Request

func (*Request) Request

func (req *Request) Request(ctx context.Context) (io.ReadCloser, int, error)

type RequestOption

type RequestOption func(*Request)

func WithMaxSize

func WithMaxSize(s uint64) RequestOption

type S3

type S3 struct {
	Bucket    string
	KeyPrefix string
	// contains filtered or unexported fields
}

func NewS3FromUrl

func NewS3FromUrl(ustr string) (*S3, error)

func (S3) CreateSignedUrl

func (r S3) CreateSignedUrl(ctx context.Context, key string, contentDisposition string) (string, error)

func (S3) Download

func (r S3) Download(ctx context.Context, key string) (io.ReadCloser, int, error)

func (S3) DownloadAuth added in v1.0.0

func (r S3) DownloadAuth(ctx context.Context, key string, auth dmfr.FeedAuthorization) (io.ReadCloser, int, error)

func (S3) ListKeys added in v1.0.0

func (r S3) ListKeys(ctx context.Context, prefix string) ([]string, error)

func (*S3) SetSecret added in v1.0.0

func (r *S3) SetSecret(secret dmfr.Secret) error

func (S3) Upload

func (r S3) Upload(ctx context.Context, key string, uploadFile io.Reader) error

type Store

type Store interface {
	Downloader
	Uploader
	CanSetSecret
	ListKeys(ctx context.Context, prefix string) ([]string, error)
}

func GetStore

func GetStore(ustr string) (Store, error)

Store returns a configured store based on the provided url.

type Uploader

type Uploader interface {
	Upload(context.Context, string, io.Reader) error
}

Jump to

Keyboard shortcuts

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