storage

package
v0.0.0-...-c3dab33 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2016 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FileSystem constant value
	FileSystem = 0
	// LevelDB constant value
	LevelDB = 1
)

Variables

View Source
var (
	// ErrUnsupportedMIMEType error value
	ErrUnsupportedMIMEType = errors.New("unsupported MIME type")
	// ErrUnsupportedFileExtension error value
	ErrUnsupportedFileExtension = errors.New("unsupported file extension")
	// ErrInvalidJSON error value
	ErrInvalidJSON = errors.New("invalid json")
)

Functions

This section is empty.

Types

type FileSystemStore

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

FileSystemStore structure

func NewFileSystemStore

func NewFileSystemStore() (fs *FileSystemStore)

NewFileSystemStore constructor

func (*FileSystemStore) Exists

func (fs *FileSystemStore) Exists(id string) (exists bool, err error)

Exists method

func (*FileSystemStore) Fetch

func (fs *FileSystemStore) Fetch(id string) (img image.Image, err error)

Fetch method

func (*FileSystemStore) Remove

func (fs *FileSystemStore) Remove(id string) (err error)

Remove method

func (*FileSystemStore) Save

func (fs *FileSystemStore) Save(id string, img image.Image) (err error)

Save method

type Item

type Item struct {
	Width     int       `codec:"width" json:"width"`
	Height    int       `codec:"height" json:"height"`
	CreatedAt time.Time `codec:"created_at" json:"created_at"`
	UpdatedAt time.Time `codec:"updated_at" json:"updated_at"`
	// 登録者情報
	IP string `codec:"ip" json:"-"`
	UA string `codec:"ua" json:"-"`
	// 画像データ
	Webp []byte `codec:"file" json:"-"`
	// 汎用メタデータ (JSON) for MessagePack
	MsgpData []byte `codec:"data" json:"-"`
	// 汎用メタデータ (JSON) for API
	JSONData map[string]interface{} `codec:"-" json:"data"`
}

Item structure for storage

type LevelDBStore

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

LevelDBStore structure (implement store interface)

func NewLevelDBStore

func NewLevelDBStore() (ld *LevelDBStore)

NewLevelDBStore constructor

func (*LevelDBStore) Exists

func (ld *LevelDBStore) Exists(id string) (exists bool, err error)

Exists method

func (*LevelDBStore) Fetch

func (ld *LevelDBStore) Fetch(id string) (item *Item, err error)

Fetch method

func (*LevelDBStore) Keys

func (ld *LevelDBStore) Keys(prefixes ...string) (list []string, err error)

Keys method

func (*LevelDBStore) Remove

func (ld *LevelDBStore) Remove(id string) (err error)

Remove method

func (*LevelDBStore) Save

func (ld *LevelDBStore) Save(id string, item *Item) (err error)

Save method

type Storage

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

Storage structure

func NewStorage

func NewStorage(storeType int) (storage *Storage)

NewStorage constructor

func (*Storage) Exists

func (storage *Storage) Exists(id string) (bool, error)

Exists method

func (*Storage) Fetch

func (storage *Storage) Fetch(id string, extension string) (buff bytes.Buffer, mimeType string, err error)

Fetch method

func (*Storage) GenerateID

func (storage *Storage) GenerateID() (id string, err error)

GenerateID will generate unique file ID

func (*Storage) Keys

func (storage *Storage) Keys(prefixes ...string) (list []string, err error)

Keys method

func (*Storage) ReadMetaData

func (storage *Storage) ReadMetaData(id string) (item *Item, err error)

ReadMetaData method

func (*Storage) Remove

func (storage *Storage) Remove(id string) error

Remove method

func (*Storage) Save

func (storage *Storage) Save(id string, reader io.Reader, metadata ...map[string]interface{}) (err error)

Save method

Jump to

Keyboard shortcuts

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