upload

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatBytes

func FormatBytes(bytes int64) string

FormatBytes formats a byte count as a human-readable string (e.g., "1.5 MB").

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration as a human-readable string (e.g., "1m 30s").

func FormatSpeed

func FormatSpeed(bytesPerSecond float64) string

FormatSpeed formats a speed as a human-readable string (e.g., "1.5 MB/s").

Types

type Progress

type Progress struct {
	BytesRead      int64
	BytesPerSecond float64
	Duration       time.Duration
	Fraction       float64       // 0.0–1.0 upload fraction complete
	ETA            time.Duration // estimated time remaining; 0 if unknown
}

Progress represents a snapshot of the current upload stats.

type ProgressReader

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

ProgressReader wraps an io.Reader and periodically reports upload progress.

func NewProgressReader

func NewProgressReader(r io.ReadCloser, onProgress func(Progress)) *ProgressReader

NewProgressReader creates a new progress tracking reader that wraps the given io.Reader.

func (*ProgressReader) Close added in v0.2.0

func (pr *ProgressReader) Close() error

func (*ProgressReader) GetProgress

func (pr *ProgressReader) GetProgress() Progress

GetProgress returns the current progress snapshot.

func (*ProgressReader) Read

func (pr *ProgressReader) Read(p []byte) (int, error)

Jump to

Keyboard shortcuts

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