request

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: GPL-3.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(storage string, key string) (io.ReadCloser, error)

Download is a convenience method for downloading a file from the store.

func UploadFile

func UploadFile(storage string, src string, dst string) error

UploadFile is a convenience method for uploading a file to the store.

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, secret dmfr.Secret) (string, error)

func (Az) Download

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

func (Az) Upload

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

type Downloader

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

type FetchResponse

type FetchResponse struct {
	Filename     string
	Data         []byte
	ResponseSize int
	ResponseCode int
	ResponseSHA1 string
	FetchError   error
}

func AuthenticatedRequest

func AuthenticatedRequest(address string, opts ...RequestOption) (FetchResponse, error)

AuthenticatedRequest fetches a url using a secret and auth description. Returns []byte, sha1, size, response code. Fatal errors will be returned as the error; non-fatal errors as FetchResponse.FetchError

func AuthenticatedRequestDownload

func AuthenticatedRequestDownload(address string, opts ...RequestOption) (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{}

func (Ftp) Download

func (Ftp) Download(ctx context.Context, ustr string, secret dmfr.Secret, auth dmfr.FeedAuthorization) (io.ReadCloser, int, error)

type Http

type Http struct{}

func (Http) Download

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

type Local

type Local struct {
	Directory string
}

func (Local) Download

func (r Local) Download(ctx context.Context, ustr string, secret dmfr.Secret, auth dmfr.FeedAuthorization) (io.ReadCloser, int, error)

func (Local) Exists

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

func (Local) Upload

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

type Presigner

type Presigner interface {
	CreateSignedUrl(context.Context, string, string, dmfr.Secret) (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
}

func NewS3FromUrl

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

func (S3) CreateSignedUrl

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

func (S3) Download

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

func (S3) Upload

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

type Store

type Store interface {
	Uploader
	Downloader
}

Store provides data storage methods.

func GetStore

func GetStore(ustr string) (Store, error)

GetStore returns a configured store based on the provided url.

type Uploader

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

Jump to

Keyboard shortcuts

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