storage

package
v0.0.0-...-e05d22d Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPublicUrl = errors.New("No public URL available for this file")
View Source
var ErrNotAFilesystem = errors.New("This items in this blob store can't be accessed as local files")

Functions

func ReadFile

func ReadFile(s Storage, name string) ([]byte, error)

func WriteFile

func WriteFile(s Storage, name string, content io.Reader) error

Types

type File

type File struct {
	Reader     io.ReadCloser
	ModifiedAt time.Time
	Size       int64
}

File is an element in blob storage.

type Storage

type Storage interface {
	// When finished, you must close the WriteCloser
	WriteFile(name string) (io.WriteCloser, error)

	// When finished, you must close File.Reader
	ReadFile(name string) (*File, error)

	DeleteFile(name string) error

	// Return a URL to the given file. If that is not possible, return ErrNoPublicUrl.
	URL(name string) (string, error)

	// If this is a local filesystem, then return the local path to the file.
	Filename(name string) (string, error)
}

Storage is an abstraction of a blob store (eg S3), or a filesystem

type StorageFS

type StorageFS struct {
	Root string
	// contains filtered or unexported fields
}

StorageFS is a filesystem-based blob store

func NewStorageFS

func NewStorageFS(log logs.Log, root string) (*StorageFS, error)

func (*StorageFS) DeleteFile

func (fs *StorageFS) DeleteFile(name string) error

func (*StorageFS) Filename

func (fs *StorageFS) Filename(name string) (string, error)

func (*StorageFS) ReadFile

func (fs *StorageFS) ReadFile(name string) (*File, error)

func (*StorageFS) URL

func (fs *StorageFS) URL(name string) (string, error)

func (*StorageFS) WriteFile

func (fs *StorageFS) WriteFile(name string) (io.WriteCloser, error)

type StorageGCS

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

StorageGCS is a Google Cloud Storage-based blob store

func NewStorageGCS

func NewStorageGCS(log logs.Log, bucketName string, isPublic bool) (*StorageGCS, error)

func (*StorageGCS) DeleteFile

func (s *StorageGCS) DeleteFile(name string) error

func (*StorageGCS) Filename

func (s *StorageGCS) Filename(name string) (string, error)

func (*StorageGCS) ReadFile

func (s *StorageGCS) ReadFile(name string) (*File, error)

func (*StorageGCS) URL

func (s *StorageGCS) URL(name string) (string, error)

func (*StorageGCS) WriteFile

func (s *StorageGCS) WriteFile(name string) (io.WriteCloser, error)

Jump to

Keyboard shortcuts

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