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