Documentation
¶
Index ¶
- Variables
- type Manager
- func (m *Manager) CleanupSession(id string)
- func (m *Manager) GetSession(id string) (*Session, error)
- func (m *Manager) InitSession(filePath, filename string, totalSize int64, deleteAfter bool) *Session
- func (m *Manager) InitSessionFor(filePath, filename string, totalSize int64, deleteAfter bool, ...) *Session
- func (m *Manager) Stop()
- func (m *Manager) TempDir() string
- type Session
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSessionNotFound = errors.New("download session not found") ErrSessionExpired = errors.New("download session expired") )
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Handles download sessions and their temp-file lifecycle
func NewManager ¶
New download manager and starts the cleanup loop
func (*Manager) CleanupSession ¶
Cleanup session and its temp file
func (*Manager) GetSession ¶
Get session by ID
func (*Manager) InitSession ¶
func (m *Manager) InitSession(filePath, filename string, totalSize int64, deleteAfter bool) *Session
Registers a file that is ready to be downloaded. Deletes file on cleanup if deleteAfter is true
func (*Manager) InitSessionFor ¶
func (m *Manager) InitSessionFor(filePath, filename string, totalSize int64, deleteAfter bool, serverID, creatorUserID string) *Session
InitSessionFor creates a download session bound to an owning server and creating user, so the stream handler can authorize per-server instead of globally.
type Session ¶
type Session struct {
ID string
FilePath string // file to serve
Filename string // suggested download filename
TotalSize int64
DeleteAfter bool // if true, file is deleted on session cleanup
ExpiresAt time.Time
// ServerID is the server this file belongs to and CreatorUserID the user
// who requested it. The stream handler serves bytes straight off disk
// using only the session id, so without these it can only enforce a
// global permission - meaning any user holding files:read anywhere could
// fetch another user's download if they learned the id.
ServerID string
CreatorUserID string
}
A prepared download
Click to show internal directories.
Click to hide internal directories.