Documentation
¶
Overview ¶
Package upload implements bounded, resumable, create-only file uploads.
Index ¶
- Constants
- func Error(code, message string) error
- func Feed(ctx context.Context, r io.Reader, size int64, h hash.Hash, b []byte) error
- func Hash(ctx context.Context, r io.Reader, size int64) (string, error)
- func ReadRecord(r io.Reader, scratch []byte) (byte, []byte, error)
- func ValidID(id string) bool
- func ValidName(name string) bool
- func WriteRecord(w io.Writer, kind byte, b []byte) error
- type Limits
- type Manager
- func (m *Manager) Abort(ctx context.Context, owner, id string) (Result, error)
- func (m *Manager) CheckPath(name string) error
- func (m *Manager) Description() map[string]any
- func (m *Manager) Prune(ctx context.Context, now time.Time) error
- func (m *Manager) Serve(ctx context.Context, owner string, conn net.Conn, q Request, ...) (err error)
- func (m *Manager) Status(ctx context.Context, owner, id string) (Result, error)
- type Progress
- type Ready
- type Request
- type Result
- type Spec
- type Start
Constants ¶
const ( Protocol = "file-upload-v1" OpenMethod = "files.upload.open" StatusMethod = "files.upload.status" AbortMethod = "files.upload.abort" BlockSize = 256 << 10 MetadataLimit = 16 << 10 MaxSize int64 = 1 << 40 CheckpointBytes int64 = 8 << 20 IdleTimeout = 60 * time.Second StagingDir = ".control-uploads" StartRecord byte = 1 DataRecord byte = 2 FinishRecord byte = 3 )
Variables ¶
This section is empty.
Functions ¶
func ReadRecord ¶
Records have a fixed five-byte header. The caller owns and reuses scratch; length is validated before reading or allocating any payload.
Types ¶
type Limits ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns bounded metadata and reservations; individual sessions own files and locks. Files are staged beside their destination, not in dataDir.
func (*Manager) CheckPath ¶
CheckPath keeps upload metadata and staging out of ordinary filesystem RPCs, including existing symlink and junction aliases. This is not a sandbox against programs running with the node user's unrestricted filesystem permissions.
func (*Manager) Description ¶
func (*Manager) Prune ¶
Prune is called at startup and periodically. Busy records and unresolved publication intents remain pinned. Failed deletions remain charged.
func (*Manager) Serve ¶
func (m *Manager) Serve(ctx context.Context, owner string, conn net.Conn, q Request, beforePublish func() error, progress func(int64)) (err error)
Serve performs one attempt. No connection or mutation is replayed. The node keeps authorization and maintenance admission alive for the entire call.
type Result ¶
type Result struct {
Spec
NodeID string `json:"nodeId"`
State string `json:"state"`
Offset int64 `json:"offset"`
PrefixSHA256 string `json:"prefixSHA256"`
Active bool `json:"active,omitempty"`
ResumedFrom int64 `json:"resumedFrom,omitempty"`
BytesSent int64 `json:"bytesSent,omitempty"`
Updated time.Time `json:"updated"`
}