Documentation ¶
Overview ¶
Package db contains methods to store files on filesystem and metadata in database.
Index ¶
- func GCMonitor(ch <-chan *Item, closed chan struct{}, db *sql.DB, li, le *log.Logger, ...)
- func InTransaction(db *sql.DB, f func(tx *sql.Tx) error) error
- func IsNameHash(name string) bool
- func Key(secret string, salt []byte) ([]byte, []byte)
- type Item
- func (item *Item) ContentType() string
- func (item *Item) Decrement(db *sql.DB, le *log.Logger) (bool, error)
- func (item *Item) Decrypt(w io.Writer, key []byte, l *log.Logger) error
- func (item *Item) Delete(db *sql.DB, le *log.Logger) error
- func (item *Item) Encrypt(inFile io.Reader, secret string, l *log.Logger) error
- func (item *Item) FullPath() string
- func (item *Item) GetURL(r *http.Request, secure bool) *url.URL
- func (item *Item) IsFileExists() bool
- func (item *Item) IsValidSecret(secret string) ([]byte, error)
- func (item *Item) Save(db *sql.DB) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GCMonitor ¶
func GCMonitor(ch <-chan *Item, closed chan struct{}, db *sql.DB, li, le *log.Logger, period time.Duration)
GCMonitor is garbage collection monitoring to delete expired by date or counter items.
func InTransaction ¶ added in v1.2.0
InTransaction runs method f and does commit or rollback.
func IsNameHash ¶
IsNameHash checks name can be an encrypted file name.
Types ¶
type Item ¶
type Item struct { ID int64 Name string Path string Salt string Hash string Counter int Created time.Time Expired time.Time }
Item is base data struct for incoming data.
func (*Item) ContentType ¶
ContentType returns string content-type for stored file.
func (*Item) Decrement ¶
Decrement updates items' counter. The first returned parameter is "updated" flags.
func (*Item) IsFileExists ¶
IsFileExists checks item's related file exists.
func (*Item) IsValidSecret ¶
IsValidSecret checks the secret.
Click to show internal directories.
Click to hide internal directories.