minio

package
v0.0.0-...-8c930d8 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrObjectNotFound = errors.New("object not found")

ErrObjectNotFound is the error Get and Stat answer, wrapped, when the store answers 404 for the object, the object or the bucket named for it missing, as Exists answers false for both; tell it with errors.Is. The provider creates the buckets the configuration lists when it starts (see config.Minio.Bucket), so a missing bucket is one removed since, or one an option names that EnsureBucket never created.

Functions

func Client

func Client() (*minio.Client, error)

Client returns the global MinIO client or an error if it is not initialized.

func EnsureBucket

func EnsureBucket(ctx context.Context, buckets ...string) error

EnsureBucket creates each of the buckets that does not exist yet, skipping empty names. The provider does so for the buckets the configuration lists when it starts; EnsureBucket is for another bucket an option names.

func Exists

func Exists(ctx context.Context, objectKey string, opts ...*ExistsOptions) (bool, error)

Exists checks whether an object exists: false for an object the store does not hold, and for a missing bucket alike (see ErrObjectNotFound).

func List

func List(ctx context.Context, opts ...*ListOptions) iter.Seq2[ObjectInfo, error]

List lists the objects under the prefix as a sequence of object and error pairs: every object comes with a nil error, and a listing that fails ends the sequence with one pair carrying the error, as a client not initialized yet does. Of a bucket holding list/a.txt and list/b.txt, List with Prefix "list/" and Recursive yields the two objects; over a bucket that does not exist it yields one error naming the bucket. Stopping the iteration early stops the listing.

func New

func New(cfg config.Minio) (cli *minio.Client, err error)

New returns a new MinIO client with given configuration.

func PresignedGetURL

func PresignedGetURL(ctx context.Context, objectKey string, expires time.Duration, opts ...*GetOptions) (string, error)

PresignedGetURL generates a presigned GET URL with expiration capped at 7 days.

func PresignedPutURL

func PresignedPutURL(ctx context.Context, objectKey string, expires time.Duration, opts ...*PutOptions) (string, error)

PresignedPutURL generates a presigned PUT URL with expiration capped at 7 days; of the upload options only the bucket applies.

func Remove

func Remove(ctx context.Context, objectKey string, opts ...*RemoveOptions) error

Remove deletes an object from MinIO.

Types

type CopyOptions

type CopyOptions struct {
	Bucket string
}

CopyOptions configures object copy operations.

type ExistsOptions

type ExistsOptions struct {
	VersionID string
	Bucket    string
}

ExistsOptions configures existence checks.

type GetOptions

type GetOptions struct {
	VersionID string // object version ID when versioning is enabled
	Range     string // HTTP range header, e.g. "bytes=0-1024"
	Bucket    string // overwrite the bucket name set in config.
}

GetOptions represents download options.

type ListOptions

type ListOptions struct {
	Prefix    string
	Recursive bool
	Bucket    string
}

ListOptions configures object listing.

type ObjectInfo

type ObjectInfo struct {
	Key          string
	Size         int64
	ContentType  string
	ETag         string
	LastModified time.Time
	Metadata     map[string]string
}

ObjectInfo describes object metadata.

func Copy

func Copy(ctx context.Context, srcKey, dstKey string, opts ...*CopyOptions) (*ObjectInfo, error)

Copy copies an object within the same bucket.

func Get

func Get(ctx context.Context, objectKey string, opts ...*GetOptions) (io.ReadCloser, *ObjectInfo, error)

Get downloads an object and returns a reader plus metadata. An object the store does not hold answers an error that is ErrObjectNotFound to errors.Is, as a missing bucket does (see ErrObjectNotFound).

func Put

func Put(ctx context.Context, objectKey string, reader io.Reader, opts ...*PutOptions) (*ObjectInfo, error)

Put uploads an object to MinIO and returns its basic metadata.

func Stat

func Stat(ctx context.Context, objectKey string, opts ...*StatOptions) (*ObjectInfo, error)

Stat returns object metadata. An object the store does not hold answers an error that is ErrObjectNotFound to errors.Is, as a missing bucket does (see ErrObjectNotFound).

type PutOptions

type PutOptions struct {
	ContentType     string            // MIME type, auto-detected if empty
	Metadata        map[string]string // custom metadata
	ContentEncoding string
	CacheControl    string
	Bucket          string // overwrite the bucket name set in config.
	Size            int64
}

PutOptions represents upload options.

type RemoveOptions

type RemoveOptions struct {
	ForceDelete bool
	VersionID   string
	Bucket      string
}

RemoveOptions configures delete behavior.

type StatOptions

type StatOptions struct {
	VersionID string
	Bucket    string
}

StatOptions configures stat lookups.

Jump to

Keyboard shortcuts

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