s3

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedErrorResponse added in v0.4.0

type CachedErrorResponse struct {
	Code string
	Key  string
}

CachedErrorResponse can be returned when an S3 is configured with caching, and the basic details of an error response have been stored in the cache.

func (*CachedErrorResponse) Error added in v0.4.0

func (err *CachedErrorResponse) Error() string

func (*CachedErrorResponse) Is added in v0.4.0

func (err *CachedErrorResponse) Is(other error) bool

type CachedObjectInfo added in v0.4.0

type CachedObjectInfo struct {
	Key          string
	ETag         string
	Size         int64
	ContentType  string
	LastModified time.Time
	VersionID    string
}

CachedObjectInfo provides the minimum cacheable set of S3 object information that may be returned from a Get() or Stat() operation, or on Put().

func (*CachedObjectInfo) ToObjectInfo added in v0.4.0

func (info *CachedObjectInfo) ToObjectInfo() minio.ObjectInfo

ToObjectInfo converts CachedObjectInfo to returnable minio.ObjectInfo.

type Config

type Config struct {

	// KeyPrefix allows specifying a
	// prefix applied to all S3 object
	// requests, e.g. allowing you to
	// partition a bucket by key prefix.
	KeyPrefix string

	// CoreOpts are S3 client options
	// passed during initialization.
	CoreOpts minio.Options

	// PutChunkSize is the chunk size (in bytes)
	// to use when sending a byte stream reader
	// of unknown size as a multi-part object.
	PutChunkSize int64

	// ListSize determines how many items
	// to include in each list request, made
	// during calls to .WalkKeys().
	ListSize int

	// Cache is an optional type that may be
	// provided to store simple entry information
	// to speed up Get() / Stat() operations.
	Cache EntryCache
}

Config defines options to be used when opening an S3Storage, mostly options for underlying S3 client library.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default S3Storage configuration.

type EntryCache added in v0.4.0

type EntryCache interface {

	// Get should return 'found' = true when information is cached,
	// with 'info' optionally being nilable to allow caching errors.
	Get(key string) (info *CachedObjectInfo, found bool)

	// Put should cache the given information under key, with
	// nil CachedObjectInfo{} meaning a 'not found' response.
	Put(key string, info *CachedObjectInfo)
}

EntryCache should provide a cache of S3 object information for speeding up Get(), Stat() and Remove() operations.

type ReaderSize

type ReaderSize interface {
	io.Reader
	Size() int64
}

ReaderSize is an extension of the io.Reader interface that may be implemented by callers of WriteStream() in order to improve performance. When the size is known it is passed onto the underlying minio S3 library.

type S3Storage

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

S3Storage is a storage implementation that stores key-value pairs in an S3 instance at given endpoint with bucket name.

func Open

func Open(endpoint string, bucket string, cfg *Config) (*S3Storage, error)

Open opens a new S3Storage instance with given S3 endpoint URL, bucket name and configuration.

func (*S3Storage) Clean

func (st *S3Storage) Clean(ctx context.Context) error

Clean: implements Storage.Clean().

func (*S3Storage) Client

func (st *S3Storage) Client() *minio.Core

Client: returns access to the underlying S3 client.

func (*S3Storage) GetObject added in v0.2.0

GetObject wraps minio.Core{}.GetObject() to handle wrapping with our own storage library error types.

func (*S3Storage) PutObject added in v0.2.0

func (st *S3Storage) PutObject(ctx context.Context, key string, r io.Reader, opts minio.PutObjectOptions) (minio.UploadInfo, error)

PutObject wraps minio.Core{}.PutObject() to handle wrapping with our own storage library error types, and in the case of an io.Reader that does not implement ReaderSize{}, it will instead handle upload by using minio.Core{}.NewMultipartUpload() in chunks of PutChunkSize.

func (*S3Storage) ReadBytes

func (st *S3Storage) ReadBytes(ctx context.Context, key string) ([]byte, error)

ReadBytes: implements Storage.ReadBytes().

func (*S3Storage) ReadStream

func (st *S3Storage) ReadStream(ctx context.Context, key string) (io.ReadCloser, error)

ReadStream: implements Storage.ReadStream().

func (*S3Storage) Remove

func (st *S3Storage) Remove(ctx context.Context, key string) error

Remove: implements Storage.Remove().

func (*S3Storage) RemoveObject added in v0.2.0

func (st *S3Storage) RemoveObject(ctx context.Context, key string, opts minio.RemoveObjectOptions) error

RemoveObject wraps minio.Core{}.RemoveObject() to handle wrapping with our own storage library error types.

func (*S3Storage) Stat

func (st *S3Storage) Stat(ctx context.Context, key string) (*storage.Entry, error)

Stat: implements Storage.Stat().

func (*S3Storage) StatObject added in v0.2.0

func (st *S3Storage) StatObject(ctx context.Context, key string, opts minio.StatObjectOptions) (minio.ObjectInfo, error)

StatObject wraps minio.Core{}.StatObject() to handle wrapping with our own storage library error types.

func (*S3Storage) WalkKeys

func (st *S3Storage) WalkKeys(ctx context.Context, opts storage.WalkKeysOpts) error

WalkKeys: implements Storage.WalkKeys().

func (*S3Storage) WriteBytes

func (st *S3Storage) WriteBytes(ctx context.Context, key string, value []byte) (int, error)

WriteBytes: implements Storage.WriteBytes().

func (*S3Storage) WriteStream

func (st *S3Storage) WriteStream(ctx context.Context, key string, r io.Reader) (int64, error)

WriteStream: implements Storage.WriteStream().

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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