lx4556332 / Minio.AspNetCore

AspNetCore integration for Minio client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ’₯ Minio.AspNetCore πŸ’₯

License Nuget Downloads Tests codecov

⚑️ Microsoft.Extensions.DependencyInjection and HealthChecks extensions for Minio client ⚑️

πŸ”§ Installation πŸ”§

$> dotnet add package Minio.AspNetCore

🎨 Usage 🎨

βœ… Add MinioClient

services.AddMinio(options =>
{
  options.Endpoint = "endpoint";
  // ...
  options.OnClientConfiguration = client =>
  {
    client.WithSSL();
  }
});

// Url based configuration
services.AddMinio(new Uri("s3://accessKey:secretKey@localhost:9000/region"));

// Get or inject
var client = serviceProvider.GetRequiredService<MinioClient>();

// Create new from factory
var client = serviceProvider.GetRequiredService<IMinioClientFactory>().CreateClient();

βœ… Multiple clients support using named options

services.AddMinio(options =>
{
  options.Endpoint = "endpoint1";
  // ...
  options.OnClientConfiguration = client =>
  {
    client.WithSSL();
  }
});

// Named extension overload
services.AddMinio("minio2", options =>
{
  options.Endpoint = "endpoint2";
  // ...
  options.OnClientConfiguration = client =>
  {
    client.WithSSL().WithTimeout(...);
  }
});

// Explicit named Configure
services.AddMinio()
  .Configure<MinioOptions>("minio3", options =>
  {
    options.Endpoint = "endpoint3";
    // ...
  });

// Get or inject first minio client
var client = serviceProvider.GetRequiredService<MinioClient>();

// Create new minio2
var client = serviceProvider.GetRequiredService<IMinioClientFactory>().CreateClient("minio2");

// Create new minio3
var client = serviceProvider.GetRequiredService<IMinioClientFactory>().CreateClient("minio3");

πŸš‘ HealthChecks πŸš‘

// Minio.AspNetCore.HealthChecks package

services.AddHealthChecks()
  .AddMinio(sp => sp.GetRequiredService<MinioClient>());

services.AddHealthChecks()
  .AddMinio(sp => sp.GetRequiredService<MinioClient>())
  .AddMinio(sp => /* Get named client from cache or create new */);

About

AspNetCore integration for Minio client

License:MIT License


Languages

Language:C# 100.0%