项目作者: appany

项目描述 :
AspNetCore integration for Minio client
高级语言: C#
项目地址: git://github.com/appany/Minio.AspNetCore.git
创建时间: 2020-10-06T17:51:43Z
项目社区:https://github.com/appany/Minio.AspNetCore

开源协议:MIT License

下载


💥 Minio.AspNetCore 💥

License
Nuget
Downloads
Tests
codecov

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

🔧 Installation 🔧

  1. $> dotnet add package Minio.AspNetCore

🎨 Usage 🎨

✅ Add MinioClient

  1. services.AddMinio(options =>
  2. {
  3. options.Endpoint = "endpoint";
  4. // ...
  5. options.ConfigureClient(client =>
  6. {
  7. client.WithSSL();
  8. });
  9. });
  10. // Url based configuration
  11. services.AddMinio(new Uri("s3://accessKey:secretKey@localhost:9000/region"));
  12. // Get or inject
  13. var client = serviceProvider.GetRequiredService<MinioClient>();
  14. // Create new from factory
  15. var client = serviceProvider.GetRequiredService<IMinioClientFactory>().CreateClient();

Multiple clients support using named options

  1. services.AddMinio(options =>
  2. {
  3. options.Endpoint = "endpoint1";
  4. // ...
  5. options.ConfigureClient(client =>
  6. {
  7. client.WithSSL();
  8. });
  9. });
  10. // Named extension overload
  11. services.AddMinio("minio2", options =>
  12. {
  13. options.Endpoint = "endpoint2";
  14. // ...
  15. options.ConfigureClient(client =>
  16. {
  17. client.WithSSL().WithTimeout(...);
  18. });
  19. });
  20. // Explicit named Configure
  21. services.AddMinio()
  22. .Configure<MinioOptions>("minio3", options =>
  23. {
  24. options.Endpoint = "endpoint3";
  25. // ...
  26. });
  27. // Get or inject first minio client
  28. var client = serviceProvider.GetRequiredService<MinioClient>();
  29. // Create new minio2
  30. var client = serviceProvider.GetRequiredService<IMinioClientFactory>().CreateClient("minio2");
  31. // Create new minio3
  32. var client = serviceProvider.GetRequiredService<IMinioClientFactory>().CreateClient("minio3");

🚑 HealthChecks 🚑

  1. // Minio.AspNetCore.HealthChecks package
  2. services.AddHealthChecks()
  3. .AddMinio(sp => sp.GetRequiredService<MinioClient>());
  4. services.AddHealthChecks()
  5. .AddMinio(sp => sp.GetRequiredService<MinioClient>())
  6. .AddMinio(sp => /* Get named client from cache or create new */);

Breaking changes

  • From 4.x to 5.x
    • Target frameworks support netstandard, .net6 and .net7
    • Minio upgraded to 5.0.0
  • From 3.x to 4.x
    • Minio upgraded to 4.0.0
    • options.OnClientConfiguration replaced with options.ConfigureClient(...)
  • From 5.x to 6.x
    • Minio upgraded to 6.0.1
    • DI client type changed from MinioClient to IMinioClient