uploader

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(opts Opts) (string, error)

Run executes the upload process

Types

type Opts

type Opts struct {

	// Original name of the file to uploaded
	InfileName string
	// ReadSeeker for the content of the upload
	InfileHandle io.ReadSeeker

	// Enable gzip compression on the upload
	ForceGzip bool
	// Set specific mime-type instead of detected from extension
	OverrideMimeType string
	// Use filename from template
	UseCalculatedFilename bool

	// BaseURL to reach the uploaded content
	BaseURL string
	// Template to calculate the uploaded filename from
	FileTemplate string
	// If set this bar will be provided with the progress
	ProgressBar *pb.ProgressBar

	// Bucket to upload into
	Bucket string
	// Endpoint if using MinIO or any other S3-compatible storage
	Endpoint string
}

Opts define how the upload works

func (Opts) With

func (o Opts) With(setters ...OptsSetter) Opts

With returns a copy of the original Opts with all setters applied

type OptsSetter

type OptsSetter func(*Opts)

OptsSetter defines a function type to set options

func WithBucket

func WithBucket(b string) OptsSetter

WithBucket sets the bucket for the upload

func WithCalculatedFilename

func WithCalculatedFilename(template string) OptsSetter

WithCalculatedFilename enables filename calculation

func WithEndpoint

func WithEndpoint(e string) OptsSetter

WithEndpoint sets a custom endpoint for S3 connection

func WithFile

func WithFile(name string, handle io.ReadSeeker) OptsSetter

WithFile sets the name and handle for the file to upload

func WithGzip

func WithGzip() OptsSetter

WithGzip enables Gzip compression for the uploaded file

func WithMimeType

func WithMimeType(t string) OptsSetter

WithMimeType sets the mime-type for the upload

func WithProgress

func WithProgress() OptsSetter

WithProgress enables progressbar output for the upload

Jump to

Keyboard shortcuts

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