s3client

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteBucket

func DeleteBucket(ctx context.Context, cfg Config, bucket string) error

DeleteBucket empties bucket (removing every object) and then removes the bucket itself — S3 requires a bucket to be empty before it can be removed.

func ListBuckets

func ListBuckets(ctx context.Context, cfg Config) ([]string, error)

ListBuckets returns the names of every bucket visible to the credentials in cfg. Unlike Client, which is scoped to one bucket, this is a package-level admin helper for callers that need to enumerate buckets across an entire endpoint (e.g. test cleanup).

func TestConnection

func TestConnection(ctx context.Context, cfg Config) error

TestConnection checks connectivity/credentials against an S3-compatible endpoint without needing any particular bucket to exist yet — backs an admin "test connection" API.

Types

type Client

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

func New

func New(cfg Config, bucket string) (*Client, error)

New constructs a client scoped to one bucket. PathStyle:true maps to minio.Options{BucketLookup: minio.BucketLookupPath} — required for Garage.

func (*Client) BucketExists

func (c *Client) BucketExists(ctx context.Context) (bool, error)

BucketExists reports whether the bucket already exists, without creating it.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, path string) error

func (*Client) EnsureBucket

func (c *Client) EnsureBucket(ctx context.Context) error

EnsureBucket idempotently creates the bucket if it doesn't exist (BucketExists -> MakeBucket). Mirrors internal/service/v1/vault/vault.go's tolerance of CouchDbDatabaseAlreadyExists for adminClient.CreateDatabase — if MakeBucket fails because the bucket now exists (race), that's not an error either.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string) (storage.Object, error)

func (*Client) List

func (c *Client) List(ctx context.Context) ([]storage.ObjectEntry, error)

func (*Client) Move

func (c *Client) Move(ctx context.Context, oldPath, newPath string) error

Move copies the object to newPath then removes oldPath — minio-go has no native rename/move.

func (*Client) Put

func (c *Client) Put(ctx context.Context, path string, content []byte, mimeType string) error

func (*Client) Stat

func (c *Client) Stat(ctx context.Context, path string) (storage.ObjectEntry, error)

func (*Client) TotalSize

func (c *Client) TotalSize(ctx context.Context) (int64, error)

TotalSize sums Size across every object in the bucket — S3 has no built-in aggregate stat, so this walks the full object listing.

type Config

type Config struct {
	Endpoint  string
	Region    string
	AccessKey string
	SecretKey string
	UseSSL    bool
	PathStyle bool // required true for Garage (https://garagehq.deuxfleurs.fr/) and most self-hosted S3-compatible stores
}

Jump to

Keyboard shortcuts

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