105067 使用appsetting中的配置注入MinIo
This commit is contained in:
parent
3024bb1d62
commit
4caab82c40
|
@ -13,6 +13,8 @@ using Microsoft.AspNetCore.DataProtection;
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using System.Runtime;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace LFlow.Base;
|
||||
/// <summary>
|
||||
|
@ -24,6 +26,7 @@ public static class Program
|
|||
/// 入口
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
///
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
|
@ -67,17 +70,19 @@ public static class Program
|
|||
{
|
||||
c.Conventions.Add(new ApiExplorerGroupPerVersionConvention());
|
||||
});
|
||||
string endPoint = "192.168.3.85:9000";
|
||||
string accessKey = "minioadmin";
|
||||
string secretKey = "minioadmin";
|
||||
bool secure = false;
|
||||
|
||||
//注入IMinIo
|
||||
builder.Services.AddSingleton<IMinioClient>
|
||||
(s =>
|
||||
new MinioClient()
|
||||
.WithEndpoint(endPoint)
|
||||
.WithCredentials(accessKey, secretKey)
|
||||
.WithSSL(secure)
|
||||
.Build()
|
||||
{
|
||||
var config = builder.Configuration.GetSection("MinIoConfig");
|
||||
IMinioClient client = new MinioClient()
|
||||
.WithEndpoint(config.GetSection("endPoint").Value)
|
||||
.WithCredentials(config.GetSection("AccessKey").Value, config.GetSection("SecretKey").Value)
|
||||
.WithSSL(false)
|
||||
.Build();
|
||||
return client;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
using Minio.DataModel.Result;
|
||||
using Minio.Exceptions;
|
||||
using Minio;
|
||||
using Minio.DataModel.Args;
|
||||
using Minio.Exceptions;
|
||||
using Minio;
|
||||
using Minio.DataModel.Result;
|
||||
|
||||
|
||||
|
||||
namespace LFlow.Base.Utils
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
]
|
||||
},
|
||||
"MinIoConfig": {
|
||||
"EndPoint": "172.30.20.40:9000",
|
||||
"AccessKey": "name",
|
||||
"SecretKey": "passsword",
|
||||
"UseSSL": false
|
||||
"EndPoint": "192.168.3.85:9000",
|
||||
"AccessKey": "minioadmin",
|
||||
"SecretKey": "minioadmin",
|
||||
"UseSSL": true
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
|
|
Loading…
Reference in New Issue