diff --git a/LFlow.Base/Program.cs b/LFlow.Base/Program.cs index 8608297..537de57 100644 --- a/LFlow.Base/Program.cs +++ b/LFlow.Base/Program.cs @@ -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; /// @@ -24,6 +26,7 @@ public static class Program /// 入口 /// /// + /// 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 (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; + } ); diff --git a/LFlow.Base/Utils/BucketManager.cs b/LFlow.Base/Utils/BucketManager.cs index 4acdf5d..a3c0c99 100644 --- a/LFlow.Base/Utils/BucketManager.cs +++ b/LFlow.Base/Utils/BucketManager.cs @@ -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 diff --git a/LFlow.Base/appsettings.json b/LFlow.Base/appsettings.json index ae5d785..7c0c5eb 100644 --- a/LFlow.Base/appsettings.json +++ b/LFlow.Base/appsettings.json @@ -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": {