diff --git a/IRaCIS.Core.Application/Helper/OSSService.cs b/IRaCIS.Core.Application/Helper/OSSService.cs index 86d3d3305..217fe9211 100644 --- a/IRaCIS.Core.Application/Helper/OSSService.cs +++ b/IRaCIS.Core.Application/Helper/OSSService.cs @@ -527,40 +527,47 @@ public class OSSService : IOSSService } else if (ObjectStoreServiceOptions.ObjectStoreUse == "MinIO") { + + var httpClientHandler = new HttpClientHandler + { + ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator + }; + var minIOConfig = ObjectStoreServiceOptions.MinIO; var minioClient = new MinioClient() .WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}") .WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey) .WithSSL(minIOConfig.UseSSL) + .WithHttpClient(new HttpClient(httpClientHandler)) .Build(); #region 废弃3 - //var pipe = new System.IO.Pipelines.Pipe(); + var pipe = new System.IO.Pipelines.Pipe(); - //_ = Task.Run(async () => - //{ - // try - // { - // var args = new GetObjectArgs() - // .WithBucket(minIOConfig.BucketName) - // .WithObject(ossRelativePath) - // .WithCallbackStream(async source => - // { - // await source.CopyToAsync(pipe.Writer.AsStream()); - // await pipe.Writer.FlushAsync(); - // }); + _ = Task.Run(async () => + { + try + { + var args = new GetObjectArgs() + .WithBucket(minIOConfig.BucketName) + .WithObject(ossRelativePath) + .WithCallbackStream(async source => + { + await source.CopyToAsync(pipe.Writer.AsStream()); + await pipe.Writer.FlushAsync(); + }); - // await minioClient.GetObjectAsync(args); - // } - // finally - // { - // await pipe.Writer.CompleteAsync(); - // } - //}); + await minioClient.GetObjectAsync(args); + } + finally + { + await pipe.Writer.CompleteAsync(); + } + }); - //return pipe.Reader.AsStream(); + return pipe.Reader.AsStream(); #endregion @@ -599,16 +606,16 @@ public class OSSService : IOSSService #region 废弃 - var memoryStream = new MemoryStream(); + //var memoryStream = new MemoryStream(); - var getObjectArgs = new GetObjectArgs() - .WithBucket(minIOConfig.BucketName) - .WithObject(ossRelativePath) - .WithCallbackStream(stream => stream.CopyToAsync(memoryStream)); + //var getObjectArgs = new GetObjectArgs() + // .WithBucket(minIOConfig.BucketName) + // .WithObject(ossRelativePath) + // .WithCallbackStream(stream => stream.CopyToAsync(memoryStream)); - await minioClient.GetObjectAsync(getObjectArgs); - memoryStream.Position = 0; - return memoryStream; + //await minioClient.GetObjectAsync(getObjectArgs); + //memoryStream.Position = 0; + //return memoryStream; #endregion