cmd_utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableAuthCheck

func DisableAuthCheck(cmd *cobra.Command)

func DownloadFileThroughUrl

func DownloadFileThroughUrl(file string, downloadUrl string)

DownloadFileThroughUrl downloads a single file from the given downloadUrl. file is the absolute path of the file to be downloaded. downloadUrl is the pre-signed url to download the file from.

func IsAuthCheckEnabled

func IsAuthCheckEnabled(cmd *cobra.Command) bool

func UploadFileThroughUrl

func UploadFileThroughUrl(um *UploadManager, file string, uploadUrl string) error

UploadFileThroughUrl uploads a single file to the given uploadUrl. um is the upload manager to use. file is the absolute path of the file to be uploaded. uploadUrl is the pre-signed url to upload the file to.

Types

type Progress

type Progress struct {
	PrintPrefix string
	TotalSize   int64
	BytesRead   int64
}

Progress is a simple struct to keep track of the progress of a file upload/download

func (*Progress) Print

func (pr *Progress) Print()

Print displays the current progress of the file upload each time Write is called

func (*Progress) Write

func (pr *Progress) Write(p []byte) (n int, err error)

Write is used to satisfy the io.Writer interface. Instead of writing somewhere, it simply aggregates the total bytes on each read

type UploadManager

type UploadManager struct {
	Errs []UploadManagerErr
	sync.WaitGroup
	// contains filtered or unexported fields
}

UploadManager is a manager for uploading files through minio client. Note that it's user's responsibility to check the Errs field after Wait() to see if there's any error.

func NewUploadManager

func NewUploadManager(client *minio.Client) (*UploadManager, error)

func (*UploadManager) AddUploadedFile

func (u *UploadManager) AddUploadedFile(name string)

AddUploadedFile sends a message to status monitor to add uploaded file.

func (*UploadManager) FMultipartPutObject

func (u *UploadManager) FMultipartPutObject(ctx context.Context, bucket string, key string, filePath string, fileSize int64, opts minio.PutObjectOptions) (err error)

func (*UploadManager) FPutObject

func (u *UploadManager) FPutObject(absPath string, bucket string, key string, sha256 string, userTags map[string]string) error

FPutObject uploads a file to a bucket with a key and sha256. If the file size is larger than minPartSize, it will use multipart upload.

func (*UploadManager) Wait

func (u *UploadManager) Wait()

Wait waits for all uploads to finish. And wait for status monitor to finish.

type UploadManagerErr

type UploadManagerErr struct {
	Err  error
	Path string
}

Jump to

Keyboard shortcuts

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