upload

package
v0.22.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultChunkBytes          = 256 * 1024
	DefaultMaxFiles            = 8
	DefaultMaxFileBytes        = 20 * 1024 * 1024
	DefaultMaxBatchBytes       = 50 * 1024 * 1024
	DefaultMaxSessions         = 64
	DefaultMaxSessionsPerOwner = 4
	DefaultSessionTTL          = 30 * time.Minute
	DefaultAttachmentTTL       = 7 * 24 * time.Hour
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment added in v0.20.0

type Attachment struct {
	Ref       string    `json:"ref"`
	Name      string    `json:"name"`
	MediaType string    `json:"media_type"`
	Bytes     int64     `json:"bytes"`
	SHA256    string    `json:"sha256"`
	ExpiresAt time.Time `json:"expires_at"`
	Path      string    `json:"-"`
}

type BeginRequest added in v0.20.0

type BeginRequest struct {
	Target protocol.TargetRef `json:"target"`
	Files  []FileSpec         `json:"files"`
	Owner  string             `json:"-"`
}

type BeginResult added in v0.20.0

type BeginResult struct {
	UploadID   string    `json:"upload_id"`
	ChunkBytes int       `json:"chunk_bytes"`
	ExpiresAt  time.Time `json:"expires_at"`
	Limits     Limits    `json:"limits"`
}

type ChunkRequest added in v0.20.0

type ChunkRequest struct {
	Target    protocol.TargetRef `json:"target"`
	UploadID  string             `json:"upload_id"`
	FileIndex int                `json:"file_index"`
	Sequence  int                `json:"sequence"`
	Data      []byte             `json:"data"`
	SHA256    string             `json:"sha256"`
}

type ChunkResult added in v0.20.0

type ChunkResult struct {
	FileIndex     int   `json:"file_index"`
	NextSequence  int   `json:"next_sequence"`
	ReceivedBytes int64 `json:"received_bytes"`
}

type Config added in v0.20.0

type Config struct {
	Root                string
	ChunkBytes          int
	MaxFiles            int
	MaxFileBytes        int64
	MaxBatchBytes       int64
	MaxSessions         int
	MaxSessionsPerOwner int
	SessionTTL          time.Duration
	AttachmentTTL       time.Duration
	Now                 func() time.Time
	Random              io.Reader
	// Logger records index recovery. Nil discards those records.
	Logger *slog.Logger
}

type Error added in v0.20.0

type Error struct {
	Code string         `json:"code"`
	Args map[string]any `json:"args,omitempty"`
}

func (*Error) Error added in v0.20.0

func (e *Error) Error() string

type FileDigest added in v0.20.0

type FileDigest struct {
	FileIndex int    `json:"file_index"`
	SHA256    string `json:"sha256"`
}

type FileSpec added in v0.20.0

type FileSpec struct {
	Name      string `json:"name"`
	MediaType string `json:"media_type"`
	Bytes     int64  `json:"bytes"`
}

type FinishRequest added in v0.20.0

type FinishRequest struct {
	Target   protocol.TargetRef `json:"target"`
	UploadID string             `json:"upload_id"`
	Files    []FileDigest       `json:"files"`
}

type FinishResult added in v0.20.0

type FinishResult struct {
	Attachments []Attachment `json:"attachments"`
}

type Limits added in v0.20.0

type Limits struct {
	MaxFiles      int   `json:"max_files"`
	MaxFileBytes  int64 `json:"max_file_bytes"`
	MaxBatchBytes int64 `json:"max_batch_bytes"`
}

type Manager added in v0.20.0

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager added in v0.20.0

func NewManager(config Config) (*Manager, error)

func (*Manager) Begin added in v0.20.0

func (m *Manager) Begin(request BeginRequest) (BeginResult, error)

func (*Manager) Cancel added in v0.20.0

func (m *Manager) Cancel(target protocol.TargetRef, uploadID string) error

func (*Manager) Chunk added in v0.20.0

func (m *Manager) Chunk(request ChunkRequest) (ChunkResult, error)

func (*Manager) Cleanup added in v0.20.0

func (m *Manager) Cleanup() int

func (*Manager) Close added in v0.20.0

func (m *Manager) Close() error

func (*Manager) Finish added in v0.20.0

func (m *Manager) Finish(request FinishRequest) (FinishResult, error)

func (*Manager) Resolve added in v0.20.0

func (m *Manager) Resolve(target protocol.TargetRef, ref string) (Attachment, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL