storage

package
v0.0.0-...-1967991 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilesystemStorage

type FilesystemStorage struct {
	FsStorageRootDir string
	StaticFilesPath  string
}

FilesystemStorage implements Storage using the disk filesystem as a storage media

func (FilesystemStorage) DeleteFile

func (fs FilesystemStorage) DeleteFile(path string) error

func (FilesystemStorage) GetRoot

func (fs FilesystemStorage) GetRoot() string

func (FilesystemStorage) SaveFile

func (fs FilesystemStorage) SaveFile(name string, data []byte) (string, error)

type Storage

type Storage interface {
	// SaveFile gets the name of a file to save and the data as bytes.
	// It saves the file somewhere (according to the implementation),
	// then returns the locationUrl.
	//
	// The locationUrl can be a full HTTP URL or a relative URL starting with /.
	// In case it begins with /, the prefix is intended to be the current server.
	SaveFile(path string, data []byte) (locationUrl string, err error)

	// DeleteFile deletes a stored file given its path.
	// It should have been saved using the same Storage implementation.
	DeleteFile(path string) error

	// GetRoot returns the root path (on this device or somewhere else) that this storage implementation
	// is using to save given data.
	GetRoot() string
}

Storage is an abstraction and can be any storage (filesystem, S3 bucket, CDN, in-memory, ...)

Jump to

Keyboard shortcuts

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