fs

package
v0.0.0-...-dadc0a5 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Type is the type of file system to use
	Type  string      `toml:"type"`
	Local LocalConfig `toml:"local"`
	S3    S3Config    `toml:"s3"`
}

Config is a configuration for the file storage backend

type Local

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

Local implements local file storage

func NewLocal

func NewLocal(rootDir string) (*Local, error)

func (*Local) Create

func (l *Local) Create(_ctx context.Context, name string, reader io.Reader) (int64, error)

func (*Local) Delete

func (l *Local) Delete(_ctx context.Context, name string) error

func (*Local) Open

func (l *Local) Open(name string) (http.File, error)

func (*Local) Size

func (l *Local) Size(_ctx context.Context, name string) (int64, error)

type LocalConfig

type LocalConfig struct {
	DataDir string `toml:"data_dir"`
}

LocalConfig is the storage configuration for local file system

type S3

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

S3 implements file storage for S3-compatible providers.

func NewS3

func NewS3(c S3Config) (*S3, error)

func (*S3) Create

func (s *S3) Create(ctx context.Context, name string, reader io.Reader) (int64, error)

func (*S3) Delete

func (s *S3) Delete(ctx context.Context, name string) error

func (*S3) Open

func (s *S3) Open(_name string) (http.File, error)

func (*S3) Size

func (s *S3) Size(ctx context.Context, name string) (int64, error)

type S3Config

type S3Config struct {
	// S3 Bucket to store files
	Bucket string `toml:"bucket"`
	// Region of the S3 service
	Region string `toml:"region"`
	// EndpointURL is an HTTP endpoint of the S3 API
	EndpointURL string `toml:"endpoint_url"`
	// Prefix is a prefix (subfolder) to use to build key names
	Prefix string `toml:"prefix"`
}

S3Config is the configuration for a S3-compatible storage provider

type Storage

type Storage interface {
	// FileSystem must be implemented to in order to pass Storage interface to HTTP file server.
	http.FileSystem

	// Create will create a new file from reader
	Create(ctx context.Context, name string, reader io.Reader) (int64, error)

	// Delete deletes the file
	Delete(ctx context.Context, name string) error

	// Size returns a storage object's size in bytes
	Size(ctx context.Context, name string) (int64, error)
}

Storage is a file system interface to host downloaded episodes and feeds.

Jump to

Keyboard shortcuts

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