storage

package
v0.0.0-...-7e8a30b Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AvailableStorageTypes = []string{"S3", "File"}
	ErrUnknownStorage     = errors.New("specify unknown storage.")
)
View Source
var (
	ErrImageNotFound = errors.New("not found requested image")
)

Functions

This section is empty.

Types

type BackwardCompatibleS3Storage

type BackwardCompatibleS3Storage struct {
	Storage
	// contains filtered or unexported fields
}

func (*BackwardCompatibleS3Storage) BuildKey

func (s *BackwardCompatibleS3Storage) BuildKey(key string) string

func (*BackwardCompatibleS3Storage) Fetch

func (s *BackwardCompatibleS3Storage) Fetch(key string) (*Object, error)

func (*BackwardCompatibleS3Storage) List

func (*BackwardCompatibleS3Storage) Move

func (s *BackwardCompatibleS3Storage) Move(from string, to string) error

func (*BackwardCompatibleS3Storage) Open

func (*BackwardCompatibleS3Storage) Put

func (s *BackwardCompatibleS3Storage) Put(key string, imageFile io.ReadSeeker, contentType string, metadata map[string]string) error

func (*BackwardCompatibleS3Storage) PutFromBlob

func (s *BackwardCompatibleS3Storage) PutFromBlob(key string, image []byte, contentType string, metadata map[string]string) error

type BackwardCompatibleS3StorageItem

type BackwardCompatibleS3StorageItem struct {
	StorageItem

	Object *s3.Object
}

func (*BackwardCompatibleS3StorageItem) Extension

func (s *BackwardCompatibleS3StorageItem) Extension() string

func (*BackwardCompatibleS3StorageItem) Filename

func (*BackwardCompatibleS3StorageItem) ImageSize

func (s *BackwardCompatibleS3StorageItem) ImageSize() string

KeyFormat: :image_type/:id/:id.original.:date.:format or :image_type/:id/:id.:format

func (*BackwardCompatibleS3StorageItem) IsValid

func (*BackwardCompatibleS3StorageItem) Key

type ErrInvalidStorageOption

type ErrInvalidStorageOption struct {
	Message string
	// contains filtered or unexported fields
}

func (*ErrInvalidStorageOption) Error

func (e *ErrInvalidStorageOption) Error() string

type FileStorage

type FileStorage struct {
	Storage
	// contains filtered or unexported fields
}

func (*FileStorage) BuildKey

func (s *FileStorage) BuildKey(key string) string

func (*FileStorage) Fetch

func (s *FileStorage) Fetch(key string) (*Object, error)

func (*FileStorage) List

func (s *FileStorage) List(key string) ([]StorageItem, error)

func (*FileStorage) Move

func (s *FileStorage) Move(from string, to string) error

func (*FileStorage) Open

func (s *FileStorage) Open() error

func (*FileStorage) Put

func (s *FileStorage) Put(key string, imageFile io.ReadSeeker, contentType string, metadata map[string]string) error

func (*FileStorage) PutFromBlob

func (s *FileStorage) PutFromBlob(key string, image []byte, contentType string, metadata map[string]string) error

type FileStorageItem

type FileStorageItem struct {
	StorageItem

	Name string
}

func (*FileStorageItem) Extension

func (s *FileStorageItem) Extension() string

func (*FileStorageItem) Filename

func (s *FileStorageItem) Filename() string

func (*FileStorageItem) ImageSize

func (s *FileStorageItem) ImageSize() string

KeyFormat: :image_type/:id/:id.:size.:format

func (*FileStorageItem) IsValid

func (s *FileStorageItem) IsValid() bool

func (*FileStorageItem) Key

func (s *FileStorageItem) Key() string

type Object

type Object struct {
	Body     []byte
	Metadata map[string]string
}

type S3Storage

type S3Storage struct {
	Storage
	// contains filtered or unexported fields
}

func (*S3Storage) BuildKey

func (s *S3Storage) BuildKey(key string) string

func (*S3Storage) Fetch

func (s *S3Storage) Fetch(key string) (*Object, error)

func (*S3Storage) List

func (s *S3Storage) List(key string) ([]StorageItem, error)

func (*S3Storage) Move

func (s *S3Storage) Move(from string, to string) error

func (*S3Storage) Open

func (s *S3Storage) Open() error

func (*S3Storage) Put

func (s *S3Storage) Put(key string, imageFile io.ReadSeeker, contentType string, metadata map[string]string) error

func (*S3Storage) PutFromBlob

func (s *S3Storage) PutFromBlob(key string, image []byte, contentType string, metadata map[string]string) error

type S3StorageItem

type S3StorageItem struct {
	StorageItem

	Object *s3.Object
}

func (*S3StorageItem) Extension

func (s *S3StorageItem) Extension() string

func (*S3StorageItem) Filename

func (s *S3StorageItem) Filename() string

func (*S3StorageItem) ImageSize

func (s *S3StorageItem) ImageSize() string

KeyFormat: :image_type/:id/:id.:size.:format

func (*S3StorageItem) IsValid

func (s *S3StorageItem) IsValid() bool

func (*S3StorageItem) Key

func (s *S3StorageItem) Key() string

type Storage

type Storage interface {
	Open() error

	Fetch(key string) (*Object, error)

	PutFromBlob(key string, image []byte, contentType string, metadata map[string]string) error
	Put(key string, imageFile io.ReadSeeker, contentType string, metadata map[string]string) error

	List(key string) ([]StorageItem, error)

	Move(from string, to string) error
}

func Open

func Open() (Storage, error)

type StorageItem

type StorageItem interface {
	Key() string
	Filename() string
	Extension() string
	ImageSize() string
}

Jump to

Keyboard shortcuts

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