Install and use the MinIO .NET SDK
masterThe MinIO .NET SDK is a modern C# client library designed for interacting with MinIO or any S3-compatible object storage service.
Requirements
- .NET 8.0, 9.0, or 10.0
- A running MinIO or S3-compatible server
repository·master·Indexed 20 days ago
https://github.com/minio/minio-dotnetA modern C# client library for interacting with MinIO and other S3-compatible object storage services. Supports .NET 8.0, 9.0, and 10.0, providing options for direct instantiation via MinioClientBuilder or integration with ASP.NET Core dependency injection using the .AddMinio extension method.
The MinIO .NET SDK is a modern C# client library designed for interacting with MinIO or any S3-compatible object storage service.
In modern .NET applications (like ASP.NET Core), you can register the MinIO client into the service collection using the .AddMinio(endpoint) extension method. This allows the client to be injected into your services via constructor injection.
services
.AddMinio("http://localhost:9000")
.WithStaticCredentials("minioadmin", "minioadmin");To develop with the MinIO .NET SDK in VS Code:
minio-dotnet2.sln solution file should be detected automatically.Note: The repository includes pre-configured settings for debugging example projects.
JetBrains Rider provides native support for this project:
minio-dotnet2.sln.For simple applications or scenarios where dependency injection is not used, you can instantiate the client directly using the MinioClientBuilder. You must provide the server endpoint and credentials via .WithStaticCredentials(accessKey, secretKey).
var client = new MinioClientBuilder("https://minio.example.com")
.WithStaticCredentials("accessKey", "secretKey")
.Build();The MinIO .NET SDK targets net6.0 through net10.0. It is recommended to install .NET SDK 8.0 or later. Use the following commands based on your operating system:
winget or download the installer from the official Microsoft website.apt-get.# Windows
winget install Microsoft.DotNet.SDK.10
# macOS
brew install dotnet
# Linux (Debian/Ubuntu)
sudo apt-get update && sudo apt-get install -y dotnet-sdk-10.0
# Verify installation
dotnet --versionThe example projects require a running MinIO server. You can start a local instance using Docker with the following command. The default credentials for this setup are minioadmin / minioadmin.
docker run --rm -p 9000:9000 quay.io/minio/minio:latest server /dataThe repository includes two example projects to demonstrate different usage patterns:
Minio.Examples.Simple/: A minimal console application using the direct MinioClientBuilder pattern.Minio.Examples.Host/: A DI-based example using IHost that demonstrates advanced operations like bucket creation, object upload/download, listing, and bucket notifications.Start a local MinIO instance using Docker:
docker run --rm -p 9000:9000 quay.io/minio/minio:latest server /dataRun the examples using the .NET CLI:
# To run the simple console example
dotnet run --project Minio.Examples.Simple
# To run the DI-based host example
dotnet run --project Minio.Examples.Hostdocker run --rm -p 9000:9000 quay.io/minio/minio:latest server /data
# then
dotnet run --project Minio.Examples.SimpleThe Minio.Examples.Host project demonstrates integration with Microsoft.Extensions.Hosting and the AddMinio DI extension. It covers:
IHost service container.Microsoft.Extensions.Logging for structured logging.IObservable<T>.You can target a specific .NET framework (e.g., net8.0) if needed.
# Run the host example
dotnet run --project Minio.Examples.Host
# Run targeting a specific framework
dotnet run --project Minio.Examples.Host --framework net8.0The Minio.Examples.Simple project is a minimal console application that demonstrates how to use MinioClientBuilder directly without dependency injection. It covers:
dotnet run --project Minio.Examples.Simple