Skip to content

Conversation

@abolfazl-alemi-aa
Copy link
Collaborator

Summary

Refactored the MinIO package to support multi-bucket operations. This is a breaking change that removes the default bucket concept and makes all bucket operations explicit.

Motivation

The previous single-bucket design required multiple client instances to work with multiple buckets and made cross-bucket operations difficult. This refactoring enables:

  • Working with multiple buckets from a single client
  • Explicit bucket operations (clearer code)
  • Dynamic bucket management (create, delete, list)
  • Better support for multi-tenant architectures

Breaking Changes

1. Configuration

  • ❌ Removed BucketName from ConnectionConfig
  • ❌ Removed AccessBucketCreation from ConnectionConfig

2. API Signatures

All operations now require explicit bucket parameter:

// Before
client.Put(ctx, "file.txt", reader, size)
client.Get(ctx, "file.txt")

// After
client.Put(ctx, "my-bucket", "file.txt", reader, minio.WithSize(size))
client.Get(ctx, "my-bucket", "file.txt")

3. Put Method Now Uses Functional Options

// Before
client.Put(ctx, key, reader, size)

// After
client.Put(ctx, bucket, key, reader,
    minio.WithSize(size),
    minio.WithContentType("text/plain"))

New Features

1. Bucket Management

client.CreateBucket(ctx, "new-bucket")
client.DeleteBucket(ctx, "old-bucket")
exists, _ := client.BucketExists(ctx, "my-bucket")
buckets, _ := client.ListBuckets(ctx)

2. BucketClient Wrapper

Convenience wrapper for repeated operations on the same bucket:

bucket := client.Bucket("user-uploads")
bucket.Put(ctx, "avatar.jpg", file, minio.WithSize(size))
data, _ := bucket.Get(ctx, "profile.jpg")

3. Functional Options

minio.WithSize(int64)
minio.WithContentType(string)
minio.WithMetadata(map[string]string)
minio.WithRegion(string)
minio.WithObjectLocking(bool)

Migration

Before:

config := minio.Config{
    Connection: minio.ConnectionConfig{
        BucketName: "my-bucket",
        AccessBucketCreation: true,
    },
}
client, _ := minio.NewClient(config)
client.Put(ctx, "file.txt", reader, size)

After:

config := minio.Config{
    Connection: minio.ConnectionConfig{
        // No bucket config
    },
}
client, _ := minio.NewClient(config)
client.CreateBucket(ctx, "my-bucket")
client.Put(ctx, "my-bucket", "file.txt", reader, minio.WithSize(size))

Introduced explicit bucket parameter for all operations, enabling multi-bucket support using a single client instance. Added `BucketClient` wrapper for repeated single-bucket use. Enhanced observability with structured logging and metrics integration. Updated documentation and examples to reflect these changes.
…tion

Defined reusable option constructors (`WithSize`, `WithContentType`, `WithMetadata`, etc.) enabling streamlined and flexible configuration for MinIO client operations. Removed redundant helper functions from tests.
@abolfazl-alemi-aa abolfazl-alemi-aa merged commit bd5d80c into main Jan 8, 2026
3 checks passed
@abolfazl-alemi-aa abolfazl-alemi-aa deleted the feat/multi-bucket-support-minio branch January 8, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants