storage

package
v0.0.0-...-fae07df Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultFilePermissions os.FileMode = 0755

Functions

This section is empty.

Types

type BaseStorage

type BaseStorage struct {
	Location string
}

func NewBaseStorage

func NewBaseStorage(location string) *BaseStorage

NewBaseStorage creates a new base storage

func (*BaseStorage) PathWithPrefix

func (s *BaseStorage) PathWithPrefix(filepath string) string

Path makes the absolte path for the file

type ContentFile

type ContentFile struct {
	*bytes.Buffer
}

func NewContentFile

func NewContentFile(content []byte) *ContentFile

func (*ContentFile) Checksum

func (f *ContentFile) Checksum() string

func (*ContentFile) Close

func (f *ContentFile) Close() error

func (*ContentFile) ReadAll

func (f *ContentFile) ReadAll() ([]byte, error)

func (*ContentFile) Size

func (f *ContentFile) Size() int64

type File

type File interface {
	Size() int64
	Read(b []byte) (int, error)
	ReadAll() ([]byte, error)
	Close() error
	Checksum() string
}

type FileSystemStorage

type FileSystemStorage struct {
	*BaseStorage
}

FileSystemStorage is a file system storage handler

func (*FileSystemStorage) Delete

func (s *FileSystemStorage) Delete(path string) error

Delete a file

func (*FileSystemStorage) Exists

func (s *FileSystemStorage) Exists(path string) bool

Exists checks if a file exists

func (*FileSystemStorage) Open

func (s *FileSystemStorage) Open(path string) (File, error)

Open file and get contents

func (*FileSystemStorage) Save

func (s *FileSystemStorage) Save(path string, f File) error

Save a file

func (*FileSystemStorage) SaveWithPermissions

func (s *FileSystemStorage) SaveWithPermissions(path string, f File, perm os.FileMode) error

Save with file permissions

type Storage

type Storage interface {
	Save(path string, f File) error
	Exists(path string) bool
	Delete(path string) error
	Open(path string) (File, error)
	PathWithPrefix(path string) string
}

Storage is an interface for multiple storage engines

func NewFileSystemStorage

func NewFileSystemStorage(location string) Storage

NewFileSystemStorage returns a file system storage engine

Jump to

Keyboard shortcuts

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