upload

package
v1.1.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package upload provides the shared chunked archive upload flow.

Index

Constants

View Source
const ChunkSize int64 = 5 * 1024 * 1024
View Source
const DefaultMaxSize int64 = 4 << 30 // 4 GiB

DefaultMaxSize bounds an upload session created against DefaultStore. It matches the backup feature's own archive size limit, but the two are independent constants: this package has no business awareness of backup.

Variables

View Source
var DefaultStore = &Store{
	Root:    filepath.Join(".", "data", ".uploading"),
	MaxSize: DefaultMaxSize,
}
View Source
var ErrNotFound = errors.New("upload not found")

Functions

This section is empty.

Types

type Finalizer

type Finalizer func(Session) (Result, error)

type Handler

type Handler struct {
	Store      *Store
	Finalizers map[Purpose]Finalizer
}

func NewHandler

func NewHandler(store *Store, finalizers map[Purpose]Finalizer) *Handler

func (*Handler) Cancel

func (h *Handler) Cancel(c *gin.Context)

func (*Handler) Chunk

func (h *Handler) Chunk(c *gin.Context)

func (*Handler) Init

func (h *Handler) Init(c *gin.Context)

func (*Handler) Merge

func (h *Handler) Merge(c *gin.Context)

type Metadata

type Metadata struct {
	Purpose  Purpose `json:"purpose"`
	Size     int64   `json:"size"`
	Filename string  `json:"filename"`
}

type Purpose

type Purpose string
const (
	PurposeBackup Purpose = "backup"
	PurposePlugin Purpose = "plugin"
	PurposeTheme  Purpose = "theme"
)

type Result

type Result struct {
	Message string
	Data    any
}

type Session

type Session struct {
	ID          string
	Metadata    Metadata
	Directory   string
	ArchivePath string
}

type Store

type Store struct {
	Root    string
	MaxSize int64
}

func (*Store) Cancel

func (s *Store) Cancel(uploadID string) error

func (*Store) Init

func (s *Store) Init(purpose Purpose, filename string, size int64) (Session, error)

func (*Store) Merge

func (s *Store) Merge(uploadID string) (Session, error)

func (*Store) SaveChunk

func (s *Store) SaveChunk(uploadID string, index int64, source io.Reader) error

Jump to

Keyboard shortcuts

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