fs

package
v0.5.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNameEmptyInvalid  = errors.New("name is empty or invalid")
	ErrConnStringInvalid = errors.New("invalid connection string")
	ErrExist             = errors.New("file already exists")
	ErrNotExist          = errors.New("file does not exist")
)

Errors

Functions

func Startup

func Startup() (err error)

Startup initializes the singleton

Types

type AzureStorage

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

AzureStorage stores files on Azure Blob Storage

func (*AzureStorage) Delete

func (f *AzureStorage) Delete(name string) (err error)

func (*AzureStorage) Get

func (f *AzureStorage) Get(name string) (found bool, data io.ReadCloser, metadata map[string]string, err error)

func (*AzureStorage) GetMetadata

func (f *AzureStorage) GetMetadata(name string) (metadata map[string]string, err error)

func (*AzureStorage) Init

func (f *AzureStorage) Init() error

func (*AzureStorage) List

func (f *AzureStorage) List() ([]FileInfo, error)

func (*AzureStorage) ListWithContext

func (f *AzureStorage) ListWithContext(ctx context.Context) ([]FileInfo, error)

func (*AzureStorage) Set

func (f *AzureStorage) Set(name string, in io.Reader, metadata map[string]string) (err error)

func (*AzureStorage) SetMetadata

func (f *AzureStorage) SetMetadata(name string, metadata map[string]string) error

func (*AzureStorage) SetWithContext

func (f *AzureStorage) SetWithContext(ctx context.Context, name string, in io.Reader, metadata map[string]string) (err error)

type FileInfo

type FileInfo struct {
	Name         string    `json:"name"`
	Size         int64     `json:"size"`
	LastModified time.Time `json:"lastModified"`
}

FileInfo object returned by the List methods

type Fs

type Fs interface {
	// Init the object
	Init() error

	// Get returns a stream to a file in the filesystem
	Get(name string) (found bool, data io.ReadCloser, metadata map[string]string, err error)

	// List returns the list of files in the filesystem
	List() ([]FileInfo, error)

	// ListWithContext is like List, but accepts a custom context object
	ListWithContext(ctx context.Context) ([]FileInfo, error)

	// Set writes a stream to the file in the filesystem
	Set(name string, in io.Reader, metadata map[string]string) (err error)

	// SetWithContext is like Set, but accepts a custom context object
	SetWithContext(ctx context.Context, name string, in io.Reader, metadata map[string]string) (err error)

	// GetMetadata returns the metadata for the file only
	GetMetadata(name string) (metadata map[string]string, err error)

	// SetMetadata updates a file's metadata in the filesystem
	SetMetadata(name string, metadata map[string]string) error

	// Delete a file from the filesystem
	Delete(name string) (err error)
}

Fs is the interface for the filesystem

var Instance Fs

Singleton

func Get

func Get(typ string) (store Fs, err error)

Get returns a store for the given type

type Local

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

Local is the local file system

func (*Local) Delete

func (f *Local) Delete(name string) error

func (*Local) Get

func (f *Local) Get(name string) (found bool, data io.ReadCloser, metadata map[string]string, err error)

func (*Local) GetMetadata

func (f *Local) GetMetadata(name string) (metadata map[string]string, err error)

func (*Local) Init

func (f *Local) Init() error

func (*Local) List

func (f *Local) List() ([]FileInfo, error)

func (*Local) ListWithContext

func (f *Local) ListWithContext(ctx context.Context) ([]FileInfo, error)

func (*Local) Set

func (f *Local) Set(name string, in io.Reader, metadata map[string]string) (err error)

func (*Local) SetMetadata

func (f *Local) SetMetadata(name string, metadata map[string]string) error

func (*Local) SetWithContext

func (f *Local) SetWithContext(ctx context.Context, name string, in io.Reader, metadata map[string]string) (err error)

type S3

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

S3 stores files on a S3-compatible service

func (*S3) Delete

func (f *S3) Delete(name string) (err error)

func (*S3) Get

func (f *S3) Get(name string) (found bool, data io.ReadCloser, metadata map[string]string, err error)

func (*S3) GetMetadata

func (f *S3) GetMetadata(name string) (metadata map[string]string, err error)

func (*S3) Init

func (f *S3) Init() error

func (*S3) List

func (f *S3) List() ([]FileInfo, error)

func (*S3) ListWithContext

func (f *S3) ListWithContext(ctx context.Context) ([]FileInfo, error)

func (*S3) Set

func (f *S3) Set(name string, in io.Reader, metadata map[string]string) (err error)

func (*S3) SetMetadata

func (f *S3) SetMetadata(name string, metadata map[string]string) error

func (*S3) SetWithContext

func (f *S3) SetWithContext(ctx context.Context, name string, in io.Reader, metadata map[string]string) (err error)

Jump to

Keyboard shortcuts

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