From 5598ae48010c17c85ca851ceea37621ddae6e63d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=BC=9F?= <421281095@qq.com> Date: Thu, 19 Jun 2025 15:34:01 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=B7=BB=E5=8A=A0=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E6=98=AFhttps=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Infrastructure/CloudSdk/minio/MinioService.cs | 10 +++++++--- OpenAuth.WebApi/appsettings.json | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Infrastructure/CloudSdk/minio/MinioService.cs b/Infrastructure/CloudSdk/minio/MinioService.cs index 36c5970..c6736fe 100644 --- a/Infrastructure/CloudSdk/minio/MinioService.cs +++ b/Infrastructure/CloudSdk/minio/MinioService.cs @@ -1,4 +1,6 @@ -using Infrastructure.Helpers; +using System.Configuration; +using Infrastructure.Extensions; +using Infrastructure.Helpers; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Minio; @@ -13,6 +15,7 @@ public class MinioService private IMinioClient _minioClient; public string _bucketName; public string endPoint; + public bool UseSSL; public MinioService() { @@ -33,6 +36,7 @@ public class MinioService var configuration = builder.Build(); _bucketName = configuration["Minio:BucketName"]; endPoint = configuration["Minio:Endpoint"]; + UseSSL = configuration["Minio:UseSSL"].ToBool(); _minioClient = new MinioClient() .WithEndpoint(endPoint) .WithCredentials(configuration["Minio:AccessKey"], configuration["Minio:SecretKey"]) @@ -181,7 +185,7 @@ public class MinioService await _minioClient.MakeBucketAsync(mbArgs).ConfigureAwait(false); } - var objectName = $"{GenerateId.GenerateOrderNumber()}.wpml"; + var objectName = $"{GenerateId.GenerateOrderNumber()}.kmz"; // 使用内存流上传 using var stream = new MemoryStream(); await file.CopyToAsync(stream); @@ -201,7 +205,7 @@ public class MinioService .WithContentType("application/octet-stream"); //.WithContentType(file.ContentType); await _minioClient.PutObjectAsync(putArgs); - return "http://" + endPoint + "/" + bucketName + "/" + objectName; + return UseSSL ? "https://" : "http://" + endPoint + "/" + bucketName + "/" + objectName; } catch (Exception ex) { diff --git a/OpenAuth.WebApi/appsettings.json b/OpenAuth.WebApi/appsettings.json index ffe292e..2d9c47e 100644 --- a/OpenAuth.WebApi/appsettings.json +++ b/OpenAuth.WebApi/appsettings.json @@ -75,6 +75,7 @@ "Password": "" }, "Minio": { + "UseSSL": false, "Endpoint": "175.27.168.120:6013", "AccessKey": "minioadmin", "SecretKey": "minioadmin",