s3

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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
}

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 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

func (st *S3Storage) GetObject(ctx context.Context, key string, opts minio.GetObjectOptions) (io.ReadCloser, minio.ObjectInfo, http.Header, error)

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().

Jump to

Keyboard shortcuts

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