files

package
v0.0.0-...-b00a9e6 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const FileNotFoundErr = "File not found"

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalStorage

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

LocalStorage implements Storage using disk.

func NewLocalStorage

func NewLocalStorage(p string) *LocalStorage

NewLocalStorage returns Storage implementation using disk.

func (*LocalStorage) GetAllInfo

func (l *LocalStorage) GetAllInfo() (*[]StorageFile, error)

GetAllInfo return all files contained in the storage.

func (*LocalStorage) Save

func (l *LocalStorage) Save(fpath string, r io.Reader) error

Save saves new file in path with content contained in r.

func (*LocalStorage) Write

func (l *LocalStorage) Write(fpath string, w io.Writer) (*StorageFile, error)

Write writes file contained in path into given w.

type Storage

type Storage interface {
	// Save creates file in fpath from r.
	Save(fpath string, f io.Reader) error

	// GetAllInfo return all StorageFiles.
	GetAllInfo() (*[]StorageFile, error)

	// Write writes StorageFile into given w.
	Write(fpath string, w io.Writer) (*StorageFile, error)
}

Storage defines file operations.

type StorageFile

type StorageFile struct {
	Path string
	Name string
	Mime string
	Size int64
	ETag string
}

StorageFile represents file located in Storage.

func NewStorageFile

func NewStorageFile(f *os.File) (*StorageFile, error)

NewStorageFile creates StorageFile from file descriptor f.

Jump to

Keyboard shortcuts

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