OSS修改
continuous-integration/drone/push Build is running
Details
continuous-integration/drone/push Build is running
Details
parent
4f83944a30
commit
a7c462210c
|
|
@ -1,4 +1,4 @@
|
||||||
using AlibabaCloud.SDK.Sts20150401;
|
using AlibabaCloud.SDK.Sts20150401;
|
||||||
using Aliyun.OSS;
|
using Aliyun.OSS;
|
||||||
using Aliyun.OSS.Common;
|
using Aliyun.OSS.Common;
|
||||||
using Amazon;
|
using Amazon;
|
||||||
|
|
@ -529,40 +529,35 @@ public class OSSService : IOSSService
|
||||||
{
|
{
|
||||||
var minIOConfig = ObjectStoreServiceOptions.MinIO;
|
var minIOConfig = ObjectStoreServiceOptions.MinIO;
|
||||||
|
|
||||||
|
|
||||||
var httpClientHandler = new HttpClientHandler
|
|
||||||
{
|
|
||||||
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
|
|
||||||
};
|
|
||||||
|
|
||||||
var minioClient = new MinioClient()
|
var minioClient = new MinioClient()
|
||||||
.WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
|
.WithEndpoint($"{minIOConfig.EndPoint}:{minIOConfig.Port}")
|
||||||
.WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey)
|
.WithCredentials(minIOConfig.AccessKeyId, minIOConfig.SecretAccessKey)
|
||||||
.WithSSL(minIOConfig.UseSSL)
|
.WithSSL(minIOConfig.UseSSL)
|
||||||
.WithHttpClient(new HttpClient(httpClientHandler))
|
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var pipe = new System.IO.Pipelines.Pipe();
|
var pipe = new System.IO.Pipelines.Pipe();
|
||||||
|
|
||||||
var args = new GetObjectArgs()
|
_ = Task.Run(async () =>
|
||||||
.WithBucket(minIOConfig.BucketName)
|
{
|
||||||
.WithObject(ossRelativePath)
|
try
|
||||||
.WithCallbackStream(async stream => // ✅ 使用异步回调
|
|
||||||
{
|
{
|
||||||
try
|
var args = new GetObjectArgs()
|
||||||
{
|
.WithBucket(minIOConfig.BucketName)
|
||||||
var pipeStream = pipe.Writer.AsStream();
|
.WithObject(ossRelativePath)
|
||||||
await stream.CopyToAsync(pipeStream); // ✅ 使用异步CopyTo
|
.WithCallbackStream(stream =>
|
||||||
await pipe.Writer.CompleteAsync();
|
{
|
||||||
}
|
stream.CopyTo(pipe.Writer.AsStream());
|
||||||
catch (Exception ex)
|
});
|
||||||
{
|
|
||||||
Log.Error($"minio 获取流错误:{ex.Message}");
|
await minioClient.GetObjectAsync(args);
|
||||||
await pipe.Writer.CompleteAsync(ex);
|
await pipe.Writer.CompleteAsync();
|
||||||
}
|
}
|
||||||
});
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await pipe.Writer.CompleteAsync(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
await minioClient.GetObjectAsync(args);
|
|
||||||
return pipe.Reader.AsStream();
|
return pipe.Reader.AsStream();
|
||||||
|
|
||||||
#region 废弃2
|
#region 废弃2
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue