Documentation ¶
Index ¶
- Variables
- func Initialize() error
- func Migrate()
- type Resource
- func (r Resource) Delete() error
- func (r *Resource) Get(key string) error
- func (r Resource) LogCreated(c *gin.Context)
- func (r Resource) LogDeleted(c *gin.Context)
- func (r Resource) LogFetched(c *gin.Context)
- func (r Resource) NewStreamWriter(fd *os.File, key []byte) (*cipher.StreamWriter, error)
- func (r Resource) OnCreated(c *gin.Context)
- func (r Resource) Save() error
- func (r Resource) Write() error
- func (r *Resource) WriteEncrypted(fd multipart.File) (string, error)
- type Statistics
Constants ¶
This section is empty.
Variables ¶
var DurationMap = map[string]time.Duration{ "30m": 30 * time.Minute, "1h": 1 * time.Hour, "6h": 6 * time.Hour, "1d": 24 * time.Hour, "1w": 24 * time.Hour * 7, }
DurationMap is a map linking the received string and a time.Duration
Functions ¶
Types ¶
type Resource ¶
type Resource struct { Key string `json:"key" storm:"id,index"` Name string `json:"name"` Once bool `json:"once"` Size int64 `json:"size"` DeleteAt time.Time `json:"delete_at" storm:"index"` UnixDeleteAt int64 `json:"unix_delete_at" storm:"index"` Duration string `json:"-"` }
Resource represents the data stored in the database
func NewResourceFromForm ¶
NewResourceFromForm returns a new Resource instance with some fields calculated
func (Resource) LogCreated ¶
LogCreated logs when a file is created
func (Resource) LogDeleted ¶
LogDeleted logs when a file is deleted (due to a one-time view)
func (Resource) LogFetched ¶
LogFetched logs when a file is fetched
func (Resource) NewStreamWriter ¶
NewStreamWriter creates a new encrypted AES stream writer with the given key and the given file descriptor
type Statistics ¶
type Statistics struct { TotalSize uint64 `json:"total_size"` TotalFiles uint64 `json:"total_files"` CurrentSize uint64 `json:"current_size"` CurrentFiles uint64 `json:"current_files"` }
Statistics is the struct representing the server statistics
var S Statistics
S is the exported main statistics structure
func (*Statistics) Add ¶
func (s *Statistics) Add(r Resource) error
Add adds the given resource to the statistics and saves it to the database
func (*Statistics) Evaluate ¶
func (s *Statistics) Evaluate() error
Evaluate recalculates the statistics from what's present in the database and save the statistics to the database
func (Statistics) Info ¶
func (s Statistics) Info()
Info prints out the information about statistics in the logs
func (*Statistics) Load ¶
func (s *Statistics) Load() error
Load loads the statistics from the database
func (*Statistics) Remove ¶
func (s *Statistics) Remove(r Resource) error
Remove removes the given resource from the current statistics and saves it to the database
func (*Statistics) Save ¶
func (s *Statistics) Save() error
Save saves the statistics to the database