upload_utils

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindMinMissingInteger added in v1.1.0

func FindMinMissingInteger(arr []int) int

FindMinMissingInteger finds the minimum missing integer in a sorted array

func IsHeadlessEnvironment added in v1.2.0

func IsHeadlessEnvironment() bool

IsHeadlessEnvironment detects if we're running in a CI/headless environment

Types

type ApiOpts added in v1.1.3

type ApiOpts struct {
	api.SecurityTokenInterface
	api.FileInterface
}

type FileInfo

type FileInfo struct {
	Path       string // Local absolute path
	RemotePath string // Remote destination path (for display)
	Size       int64
	Sha256     string
	Uploaded   int64
	Status     UploadStatusEnum
}

FileInfo contains the path, size and sha256 of a file.

type FileOpts added in v1.1.3

type FileOpts struct {
	Path string

	Recursive     bool
	IncludeHidden bool
	TargetDir     string // Target directory in remote (e.g., "data/" to upload to data/ subdirectory)

	// Additional mapping from file path to oss path
	AdditionalUploads map[string]string
	// contains filtered or unexported fields
}

func (*FileOpts) GetPaths added in v1.4.0

func (opt *FileOpts) GetPaths() []string

GetPaths returns the list of paths to upload. If glob was used, returns expanded paths; otherwise returns single Path.

func (*FileOpts) RelDir added in v1.4.0

func (opt *FileOpts) RelDir() string

RelDir returns the base directory for computing relative paths.

func (*FileOpts) Valid added in v1.1.3

func (opt *FileOpts) Valid() error

type IncUploadedMsg added in v1.1.5

type IncUploadedMsg struct {
	Path        string
	UploadedInc int64
}

IncUploadedMsg is used to send incremental uploaded size to the progress update goroutine

type IntHeap added in v1.1.0

type IntHeap []int

An IntHeap is a min-heap of ints.

func NewHeap added in v1.1.0

func NewHeap(s []int) *IntHeap

func (IntHeap) Len added in v1.1.0

func (h IntHeap) Len() int

func (IntHeap) Less added in v1.1.0

func (h IntHeap) Less(i, j int) bool

func (*IntHeap) Peek added in v1.1.0

func (h *IntHeap) Peek() int

func (*IntHeap) Pop added in v1.1.0

func (h *IntHeap) Pop() any

func (*IntHeap) Push added in v1.1.0

func (h *IntHeap) Push(x any)

func (*IntHeap) Remove added in v1.1.0

func (h *IntHeap) Remove(x any)

func (IntHeap) Swap added in v1.1.0

func (h IntHeap) Swap(i, j int)

type MultipartCheckpointInfo added in v1.1.5

type MultipartCheckpointInfo struct {
	UploadId     string               `json:"upload_id"`
	UploadedSize int64                `json:"uploaded_size"`
	Parts        []minio.CompletePart `json:"parts"`
}

MultipartCheckpointInfo contains the information needed to resume a multipart upload.

type ProjectParent added in v1.4.0

type ProjectParent struct{ P *name.Project }

ProjectParent implements UploadParent for project-level uploads.

func NewProjectParent added in v1.4.0

func NewProjectParent(p *name.Project) ProjectParent

func (ProjectParent) BuildResourceName added in v1.4.0

func (pp ProjectParent) BuildResourceName(relativePath string) string

func (ProjectParent) ParentString added in v1.4.0

func (pp ProjectParent) ParentString() string

type RecordParent added in v1.4.0

type RecordParent struct{ R *name.Record }

RecordParent implements UploadParent for record-level uploads.

func NewRecordParent added in v1.4.0

func NewRecordParent(r *name.Record) RecordParent

func (RecordParent) BuildResourceName added in v1.4.0

func (rp RecordParent) BuildResourceName(relativePath string) string

func (RecordParent) ParentString added in v1.4.0

func (rp RecordParent) ParentString() string

type TickMsg added in v1.1.4

type TickMsg time.Time

TickMsg is a message that is sent to the update function every 0.5 second.

type UploadDB added in v1.1.0

type UploadDB struct {
	*bolt.DB
}

func NewUploadDB added in v1.1.0

func NewUploadDB(filename string, recordId string, hash string, partSize uint64) (*UploadDB, error)

func (*UploadDB) Delete added in v1.1.0

func (db *UploadDB) Delete() error

Delete removes the database file from the filesystem.

func (*UploadDB) Get added in v1.1.0

func (db *UploadDB) Get(key string, objectPtr interface{}) error

Get retrieves the value of a key from the database. if the key does not exist, it returns nil.

func (*UploadDB) Reset added in v1.1.1

func (db *UploadDB) Reset() error

Reset removes all the keys from the database multipart_uploads bucket.

type UploadInfo added in v1.1.5

type UploadInfo struct {
	Path       string
	Bucket     string
	Key        string
	Tags       map[string]string
	FileReader *os.File

	// Upload result infos
	Result minio.ObjectPart
	Err    error

	// Multipart info
	UploadId        string
	PartId          int
	TotalPartsCount int
	ReadOffset      int64
	ReadSize        int64
	DB              *UploadDB
}

UploadInfo contains the information needed to upload a file or a file part (multipart upload).

type UploadManager

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

UploadManager is a manager for uploading files through minio client.

func NewUploadManagerFromConfig added in v1.1.0

func NewUploadManagerFromConfig(proj *name.Project, timeout time.Duration, apiOpts *ApiOpts, opts *UploadManagerOpts) (*UploadManager, error)

func (*UploadManager) Init added in v1.1.5

func (um *UploadManager) Init() tea.Cmd

func (*UploadManager) Run added in v1.1.3

func (um *UploadManager) Run(ctx context.Context, parent UploadParent, fileOpts *FileOpts) error

Run is used to start the upload process.

func (*UploadManager) Update added in v1.1.5

func (um *UploadManager) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*UploadManager) View added in v1.1.5

func (um *UploadManager) View() string

type UploadManagerOpts added in v1.1.5

type UploadManagerOpts struct {
	Threads  int
	PartSize string

	NoTTY bool // Force non-interactive mode
	TTY   bool // Force interactive mode
	// contains filtered or unexported fields
}

func (*UploadManagerOpts) ShouldUseInteractiveMode added in v1.2.0

func (opt *UploadManagerOpts) ShouldUseInteractiveMode() bool

ShouldUseInteractiveMode determines if interactive mode should be used

func (*UploadManagerOpts) Valid added in v1.1.5

func (opt *UploadManagerOpts) Valid() error

type UploadParent added in v1.4.0

type UploadParent interface {
	ParentString() string
	BuildResourceName(relativePath string) string
}

UploadParent is a public abstraction for upload destination (record or project).

type UploadStatusEnum

type UploadStatusEnum int

UploadStatusEnum is used to keep track of the state of a file upload

const (
	// Unprocessed is used to indicate that the file has not been processed yet
	Unprocessed UploadStatusEnum = iota

	// CalculatingSha256 is used to indicate that the file sha256 is being calculated
	CalculatingSha256

	// PreviouslyUploaded is used to indicate that the file has been uploaded before
	PreviouslyUploaded

	// WaitingForUpload is used to indicate that the file is waiting to be uploaded
	WaitingForUpload

	// UploadInProgress is used to indicate that the file upload is in progress
	UploadInProgress

	// UploadCompleted is used to indicate that the file upload has completed
	UploadCompleted

	// MultipartCompletionInProgress is used to indicate that the multipart upload completion is in progress
	MultipartCompletionInProgress

	// UploadFailed is used to indicate that the file upload has failed
	UploadFailed
)

Jump to

Keyboard shortcuts

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