storage

package
v0.0.0-...-ecb32a1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 16 Imported by: 5

Documentation

Index

Constants

View Source
const (
	DOs3StorageType = "dos3"
)

Variables

View Source
var HeaderKeys = []string{
	"Age",
	"Content-Type",
	"Last-Modified",
	"Date",
	"Etag",
}

HeaderKeys represents the list of headers

Functions

func New

func New(ctx context.Context, log *slog.Logger, cfg *Config) (*Storage, *Storage, error)

New return destination and source storages from config

Types

type Config

type Config struct {
	Destination *StorageConfig `mapstructure:"dst"`
	Source      *StorageConfig `mapstructure:"src"`
}

Config is a struct to represent a section of storage (src, fst)

type DummyStorage

type DummyStorage struct {
}

func (*DummyStorage) Delete

func (s *DummyStorage) Delete(ctx context.Context, filepath string) error

func (*DummyStorage) Open

func (s *DummyStorage) Open(ctx context.Context, filepath string) (io.ReadCloser, error)

func (DummyStorage) OpenWithStat

func (s DummyStorage) OpenWithStat(ctx context.Context, path string) (io.ReadCloser, *gostorages.Stat, error)

func (*DummyStorage) Save

func (s *DummyStorage) Save(ctx context.Context, content io.Reader, filepath string) error

func (DummyStorage) Stat

func (s DummyStorage) Stat(ctx context.Context, path string) (*gostorages.Stat, error)

type HTTPStorage

type HTTPStorage struct {
	gostorages.Storage
	// contains filtered or unexported fields
}

HTTPStorage wraps a storage

func NewHTTPStorage

func NewHTTPStorage(storage gostorages.Storage, httpclient *httppkg.Client) *HTTPStorage

func (*HTTPStorage) Headers

func (s *HTTPStorage) Headers(filepath string) (map[string]string, error)

Headers returns headers from a filepath

func (*HTTPStorage) HeadersFromURL

func (s *HTTPStorage) HeadersFromURL(u *url.URL) (map[string]string, error)

HeadersFromURL retrieves the headers from an url

func (*HTTPStorage) IsNotExist

func (s *HTTPStorage) IsNotExist(err error) bool

func (*HTTPStorage) ModifiedTime

func (s *HTTPStorage) ModifiedTime(filepath string) (time.Time, error)

ModifiedTime returns the modified time from a filepath

func (*HTTPStorage) Open

func (s *HTTPStorage) Open(ctx context.Context, filepath string) (io.ReadCloser, error)

Open retrieves a gostorages File from a filepath

func (*HTTPStorage) OpenFromURL

func (s *HTTPStorage) OpenFromURL(ctx context.Context, u *url.URL) (io.ReadCloser, error)

OpenFromURL retrieves bytes from an url

type Storage

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

Storage wraps gostorages.Storage.

func (*Storage) Delete

func (s *Storage) Delete(ctx context.Context, path string) error

func (*Storage) Open

func (s *Storage) Open(ctx context.Context, path string) (io.ReadCloser, error)

func (*Storage) OpenWithStat

func (s *Storage) OpenWithStat(ctx context.Context, path string) (io.ReadCloser, *gostorages.Stat, error)

func (*Storage) Path

func (s *Storage) Path(filepath string) string

Path returns the filepath prefixed with Location from storage.

func (*Storage) Save

func (s *Storage) Save(ctx context.Context, content io.Reader, path string) error

func (*Storage) Stat

func (s *Storage) Stat(ctx context.Context, path string) (*gostorages.Stat, error)

func (*Storage) URL

func (s *Storage) URL(filepath string) string

URL returns the filepath prefixed with BaseURL from storage.

type StorageConfig

type StorageConfig struct {
	ACL             string
	AccessKeyID     string `mapstructure:"access_key_id"`
	BaseURL         string `mapstructure:"base_url"`
	BucketName      string `mapstructure:"bucket_name"`
	CacheControl    string `mapstructure:"cache_control"`
	Location        string
	Region          string
	SecretAccessKey string `mapstructure:"secret_access_key"`
	Type            string
	Endpoint        string `mapstructure:"endpoint"`
}

StorageConfig is a struct to represent a Storage (fs, s3)

Jump to

Keyboard shortcuts

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