minio

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package minio provides a client for MinIO (S3-compatible) object storage.

Index

Constants

View Source
const (
	ErrCodeErrMinioPutObject        = "S3-001"
	ErrCodeMinioCannotGetObject     = "S3-002"
	ErrCodeMinioCannotGetStatObject = "S3-003"
	ErrCodeMinioObjectNotFound      = "S3-004"
	ErrCodeMinioCreateBucket        = "S3-005"
	ErrCodeMinioRemoveObject        = "S3-006"
	ErrCodeMinioNew                 = "S3-007"
	ErrCodeMinioCopyObject          = "S3-008"
)

Variables

View Source
var (
	ErrMinioPutObject = func(cause error, ctx context.Context) error {
		return jet.NewAppErrBuilder(ErrCodeErrMinioPutObject, "").Wrap(cause).C(ctx).Err()
	}
	ErrMinioCannotGetObject = func(cause error, ctx context.Context) error {
		return jet.NewAppErrBuilder(ErrCodeMinioCannotGetObject, "").Wrap(cause).C(ctx).Err()
	}
	ErrMinioCannotGetStatObject = func(cause error, ctx context.Context) error {
		return jet.NewAppErrBuilder(ErrCodeMinioCannotGetStatObject, "").Wrap(cause).C(ctx).Err()
	}
	ErrMinioObjectNotFound = func(ctx context.Context) error {
		return jet.NewAppErrBuilder(ErrCodeMinioObjectNotFound, "").C(ctx).Err()
	}
	ErrMinioCreateBucket = func(cause error, ctx context.Context) error {
		return jet.NewAppErrBuilder(ErrCodeMinioCreateBucket, "").Wrap(cause).C(ctx).Err()
	}
	ErrMinioRemoveObject = func(cause error, ctx context.Context, fileId string) error {
		return jet.NewAppErrBuilder(ErrCodeMinioRemoveObject, "").Wrap(cause).C(ctx).F(jet.KV{"fileID ": fileId}).Err()
	}
	ErrMinioCopyObject = func(cause error, ctx context.Context, fileId string) error {
		return jet.NewAppErrBuilder(ErrCodeMinioCopyObject, "").Wrap(cause).C(ctx).F(jet.KV{"fileID ": fileId}).Err()
	}
	ErrMinioNew = func(cause error) error {
		return jet.NewAppErrBuilder(ErrCodeMinioNew, "").Wrap(cause).Err()
	}
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Host      string
	Port      string
	AccessKey string `config:"access-key"`
	SecretKey string `config:"secret-key"`
	Ssl       bool
}

Config minio config

type FileInfo

type FileInfo struct {
	Id           string            `json:"id"`          // Id file ID
	Filename     string            `json:"fileName"`    // Filename - file name
	BucketName   string            `json:"bucket"`      // BucketName - bucket name (like storage folder)
	Extension    string            `json:"ext"`         // Extension - file ext
	LastModified string            `json:"modified"`    // LastModified - last modified date
	Size         int64             `json:"size"`        // Size - length of a file in bytes
	ContentType  string            `json:"contentType"` // ContentType - content type
	Metadata     map[string]string `json:"metadata"`    // Metadata - some additional user params attached to a stored file
}

FileInfo is a meta info about stored file

type Minio

type Minio struct {
	Instance *minio.Client
	// contains filtered or unexported fields
}

func New

func New(params *Config, logger jet.CLoggerFunc) (*Minio, error)

func (*Minio) Copy

func (a *Minio) Copy(ctx context.Context, srcBucketName, srcFileID, destBucketName, destFileId string) error

func (*Minio) CreateBucket

func (a *Minio) CreateBucket(ctx context.Context, bucketName string) error

func (*Minio) Delete

func (a *Minio) Delete(ctx context.Context, bucketName string, fileID string) error

func (*Minio) Get

func (a *Minio) Get(ctx context.Context, bucketName string, fileID string) (io.Reader, error)

func (*Minio) GetMetadata

func (a *Minio) GetMetadata(ctx context.Context, bucketName string, fileID string) (*FileInfo, error)

func (*Minio) IsBucketExist

func (a *Minio) IsBucketExist(ctx context.Context, bucketName string) bool

func (*Minio) IsFileExist

func (a *Minio) IsFileExist(ctx context.Context, bucketName string, fileID string) bool

func (*Minio) Put

func (a *Minio) Put(ctx context.Context, fi *FileInfo, file io.Reader) error

Jump to

Keyboard shortcuts

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