Documentation
¶
Overview ¶
Package avatar implements avatart proxy for oauth and defines store interface and implements local (fs), gridfs (mongo) and boltdb stores.
Index ¶
- func GenerateAvatar(user string) ([]byte, error)
- func GetGravatarURL(email string) (res string, err error)
- func Migrate(dst Store, src Store) (int, error)
- type BoltDB
- func (b *BoltDB) Close() error
- func (b *BoltDB) Get(avatarID string) (reader io.ReadCloser, size int, err error)
- func (b *BoltDB) ID(avatarID string) (id string)
- func (b *BoltDB) List() (ids []string, err error)
- func (b *BoltDB) Put(userID string, reader io.Reader) (avatar string, err error)
- func (b *BoltDB) Remove(avatarID string) (err error)
- type GridFS
- func (gf *GridFS) Close() error
- func (gf *GridFS) Get(avatar string) (reader io.ReadCloser, size int, err error)
- func (gf *GridFS) ID(avatar string) (id string)
- func (gf *GridFS) List() (ids []string, err error)
- func (gf *GridFS) Put(userID string, reader io.Reader) (avatar string, err error)
- func (gf *GridFS) Remove(avatar string) error
- type LocalFS
- func (fs *LocalFS) Close() error
- func (fs *LocalFS) Get(avatar string) (reader io.ReadCloser, size int, err error)
- func (fs *LocalFS) ID(avatar string) (id string)
- func (fs *LocalFS) List() (ids []string, err error)
- func (fs *LocalFS) Put(userID string, reader io.Reader) (avatar string, err error)
- func (fs *LocalFS) Remove(avatar string) error
- type Proxy
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateAvatar ¶ added in v0.5.0
GenerateAvatar for give user with identicon
func GetGravatarURL ¶ added in v0.6.1
GetGravatarURL returns url to gravatar picture for given email
Types ¶
type BoltDB ¶
type BoltDB struct {
// contains filtered or unexported fields
}
BoltDB implements avatar store with bolt using separate db (file) with "avatars" bucket to keep image bin and "metas" bucket to keep sha1 of picture. avatarID (base file name) used as a key for both.
type GridFS ¶
type GridFS struct {
Connection *mongo.Connection
}
GridFS implements Store for GridFS
func NewGridFS ¶
func NewGridFS(conn *mongo.Connection) *GridFS
NewGridFS makes gridfs (mongo) avatar store
func (*GridFS) ID ¶
ID returns a fingerprint of the avatar content. Uses MD5 because gridfs provides it directly
type LocalFS ¶
type LocalFS struct {
// contains filtered or unexported fields
}
LocalFS implements Store for local file system
func NewLocalFS ¶
NewLocalFS makes file-system avatar store
type Proxy ¶
Proxy provides http handler for avatars from avatar.Store On user login token will call Put and it will retrieve and save picture locally.
type Store ¶
type Store interface {
Put(userID string, reader io.Reader) (avatarID string, err error) // save avatar data from the reader and return base name
Get(avatarID string) (reader io.ReadCloser, size int, err error) // load avatar via reader
ID(avatarID string) (id string) // unique id of stored avatar's data
Remove(avatarID string) error // remove avatar data
List() (ids []string, err error) // list all avatar ids
Close() error // close store
}
Store defines interface to store and and load avatars