Documentation
¶
Index ¶
- Variables
- type Manager
- func (m *Manager) Cancel(sessionID string) error
- func (m *Manager) CleanupSession(sessionID string) error
- func (m *Manager) GetMissingChunks(sessionID string) ([]int32, error)
- func (m *Manager) GetSession(id string) (*Session, error)
- func (m *Manager) GetSessionStatus(sessionID string) (bytesReceived int64, totalBytes int64, chunksReceived int32, totalChunks int32, ...)
- func (m *Manager) GetTempPath(sessionID string) (string, string, error)
- func (m *Manager) InitSession(filename string, totalSize int64, chunkSize int32) (*Session, error)
- func (m *Manager) Stop()
- func (m *Manager) WriteChunk(sessionID string, chunkIndex int32, data []byte) (completed bool, err error)
- func (m *Manager) WriteStream(sessionID string, r io.Reader, offset int64) (bytesWritten int64, completed bool, err error)
- type Session
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSessionNotFound = errors.New("upload session not found") ErrSessionExpired = errors.New("upload session expired") ErrSessionCompleted = errors.New("upload session already completed") ErrInvalidChunk = errors.New("invalid chunk index") ErrChunkExists = errors.New("chunk already received") ErrFileTooLarge = errors.New("file exceeds maximum allowed size") ErrInvalidChunkSize = errors.New("invalid chunk size") ErrChunkTooLarge = errors.New("chunk exceeds declared chunk size") ErrUploadOverflow = errors.New("chunk would exceed declared total size") )
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles upload sessions
func NewManager ¶
func NewManager(tempDir string, sessionTTL time.Duration, maxUploadSize int64, log *logger.Logger) *Manager
NewManager creates a new upload manager
func (*Manager) CleanupSession ¶
CleanupSession removes a session after the file has been moved to its destination
func (*Manager) GetMissingChunks ¶
GetMissingChunks returns the list of chunk indices that haven't been received
func (*Manager) GetSession ¶
GetSession retrieves a session by ID
func (*Manager) GetSessionStatus ¶
func (m *Manager) GetSessionStatus(sessionID string) (bytesReceived int64, totalBytes int64, chunksReceived int32, totalChunks int32, completed bool, tempPath string, err error)
GetSessionStatus returns the status of a session
func (*Manager) GetTempPath ¶
GetTempPath returns the temp file path for a completed session
func (*Manager) InitSession ¶
InitSession creates a new upload session
type Session ¶
type Session struct {
ID string
Filename string
TotalSize int64
ChunkSize int32
TotalChunks int32
ReceivedChunks map[int32]bool
BytesReceived int64
TempPath string
ExpiresAt time.Time
Completed bool
// contains filtered or unexported fields
}
Session represents an active upload session
Click to show internal directories.
Click to hide internal directories.