storage

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: Unlicense Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyExists = errors.New("file already exists")

Functions

This section is empty.

Types

type FileHeader added in v0.0.24

type FileHeader struct {
	Info     os.FileInfo
	Metadata *Metadata
	Path     string
}

type FilePointer

type FilePointer struct {
	File     *os.File
	Info     os.FileInfo
	Metadata *Metadata
}

func (*FilePointer) Close

func (f *FilePointer) Close() error

type Metadata

type Metadata struct {
	Class    string     `cbor:"c,omitempty" json:"class,omitempty"`
	MimeType string     `cbor:"m,omitempty" json:"mime_type,omitempty"`
	Expiry   *time.Time `cbor:"e,omitempty" json:"expiry,omitempty"`

	Oneshot bool `cbor:"o,omitempty" json:"oneshot,omitempty"`
	Stream  bool `cbor:"s,omitempty" json:"stream,omitempty"`
}

func (*Metadata) HasExpiry added in v0.0.25

func (m *Metadata) HasExpiry() bool

type Params

type Params struct {
	fx.In

	Loader *config.Loader
	Ctx    context.Context
	Lc     fx.Lifecycle
	Log    *slog.Logger
}

type Result

type Result struct {
	fx.Out

	Output *Storage
}

func New

func New(p Params) (r Result, err error)

type Storage

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

func (*Storage) DeleteFile

func (o *Storage) DeleteFile(ctx context.Context, path string) error

func (*Storage) FileExists

func (o *Storage) FileExists(ctx context.Context, path string) (ok bool, err error)

func (*Storage) ListFiles added in v0.0.24

func (o *Storage) ListFiles(ctx context.Context) ([]*FileHeader, error)

func (*Storage) Migrate

func (o *Storage) Migrate() error

func (*Storage) ReadFile

func (o *Storage) ReadFile(ctx context.Context, path string) (*FilePointer, error)

the caller is responsible to close the filepointer

func (*Storage) WriteFile

func (o *Storage) WriteFile(ctx context.Context, opts *WriteFileOptions) error

type WriteFileOptions

type WriteFileOptions struct {
	File     io.Reader
	Name     string
	Metadata *Metadata
}

Jump to

Keyboard shortcuts

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