s3minio

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigDefault = Config{
	Bucket:              "goe-bucket",
	Endpoint:            "",
	Region:              "",
	BucketLookup:        BucketLookupAuto,
	Token:               "",
	Secure:              false,
	Reset:               false,
	Credentials:         Credentials{},
	GetObjectOptions:    minio.GetObjectOptions{},
	PutObjectOptions:    minio.PutObjectOptions{},
	ListObjectsOptions:  minio.ListObjectsOptions{},
	RemoveObjectOptions: minio.RemoveObjectOptions{},
}

ConfigDefault is the default config

Functions

This section is empty.

Types

type BucketLookupType

type BucketLookupType int

BucketLookupType is type of url lookup supported by server.

const (
	BucketLookupAuto BucketLookupType = iota
	BucketLookupDNS
	BucketLookupPath
)

Different types of url lookup supported by the server.Initialized to BucketLookupAuto

type Config

type Config struct {
	// Bucket
	// Default fiber-bucket
	Bucket string

	// Endpoint is a host name or an IP address
	Endpoint string

	// Region Set this value to override region cache
	// Optional
	Region string

	// BucketLookup Set this value to BucketLookupDNS or BucketLookupPath to override the default bucket lookup
	// Optional, Default is BucketLookupAuto
	BucketLookup BucketLookupType

	// Token Set this value to provide x-amz-security-token (AWS S3 specific)
	// Optional, Default is false
	Token string

	// Secure If set to true, https is used instead of http.
	// Default is false
	Secure bool

	// Reset clears any existing keys in existing Bucket
	// Optional. Default is false
	Reset bool

	// Credentials Minio access key and Minio secret key.
	// Need to be defined
	Credentials Credentials

	// GetObjectOptions Options for GET requests specifying additional options like encryption, If-Match
	GetObjectOptions minio.GetObjectOptions

	// PutObjectOptions
	// Allows user to set optional custom metadata, content headers, encryption keys and number of threads for multipart upload operation.
	PutObjectOptions minio.PutObjectOptions

	// ListObjectsOptions Options per to list objects
	ListObjectsOptions minio.ListObjectsOptions

	// RemoveObjectOptions Allows user to set options
	RemoveObjectOptions minio.RemoveObjectOptions
}

Config defines the config for storage.

type Credentials

type Credentials struct {
	// AccessKeyID is like user-id that uniquely identifies your account.
	AccessKeyID string
	// SecretAccessKey is the password to your account.
	SecretAccessKey string
}

type Storage

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

Storage interface that is implemented by storage providers

func New

func New(config ...Config) *Storage

New creates a new storage

func (*Storage) CheckBucket

func (s *Storage) CheckBucket() error

CheckBucket Check to see if bucket already exists

func (*Storage) Close

func (s *Storage) Close() error

Close the storage

func (*Storage) Conn

func (s *Storage) Conn() *minio.Client

Conn returns the minio client.

func (*Storage) CreateBucket

func (s *Storage) CreateBucket() error

CreateBucket creates a new bucket if it does not exist

func (*Storage) Delete

func (s *Storage) Delete(key string) error

Delete entry by key

func (*Storage) Get

func (s *Storage) Get(key string) ([]byte, error)

Get value by key

func (*Storage) MustGet

func (s *Storage) MustGet(key string) []byte

func (*Storage) RemoveBucket

func (s *Storage) RemoveBucket() error

RemoveBucket removes the bucket if it is empty.

func (*Storage) Reset

func (s *Storage) Reset() error

Reset all entries, including unexpired This method resets all entries in the storage, including unexpired entries. It deletes all objects in the storage bucket. The method achieves this by listing all the objects in the bucket and sending their names to a channel. A separate goroutine listens to the channel and removes the objects one by one using the minio client's RemoveObjects method. The method also logs any errors encountered during the deletion process. DANGER ZONE!!!!!!: This method is dangerous and should be used with caution. It deletes all objects in the storage bucket.

func (*Storage) Set

func (s *Storage) Set(key string, val []byte, exp time.Duration) error

Set key with value The method `Set` sets the value for a given key in the storage. It creates a Reader from the value byte slice, sets the content type in the storage configuration, and then puts the object in the bucket using the Minio client. It acquires a lock on the storage mutex to ensure thread safety when setting the configuration options. Finally, it returns any errors encountered while putting the object.

Jump to

Keyboard shortcuts

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