改成内存流测试
continuous-integration/drone/push Build is running Details

Test_HIR_Net8
hang 2026-06-05 13:37:11 +08:00
parent c8d181e557
commit 5a27fbc127
1 changed files with 35 additions and 30 deletions

View File

@ -535,32 +535,37 @@ public class OSSService : IOSSService
.WithSSL(minIOConfig.UseSSL)
.Build();
var pipe = new System.IO.Pipelines.Pipe();
#region 废弃3
_ = 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();
});
//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();
// });
// await minioClient.GetObjectAsync(args);
// }
// finally
// {
// await pipe.Writer.CompleteAsync();
// }
//});
//return pipe.Reader.AsStream();
#endregion
await minioClient.GetObjectAsync(args);
}
finally
{
await pipe.Writer.CompleteAsync();
}
});
return pipe.Reader.AsStream();
#region 废弃2
//var pipe = new System.IO.Pipelines.Pipe();
@ -594,16 +599,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