oss 异步获取流,检查时间修改格式
continuous-integration/drone/push Build is passing Details

Test_HIR_Net8
hang 2026-03-16 14:41:19 +08:00
parent 02aebab5ea
commit 88c1bf7e76
2 changed files with 54 additions and 24 deletions

View File

@ -1046,7 +1046,7 @@ namespace IRaCIS.Core.API.Controllers
{
abortToken.ThrowIfCancellationRequested();
var studyTime = study.StudyTime?.ToString("yyyy-MM-dd HH:mm:ss") ?? "UnknownTime";
var studyTime = study.StudyTime?.ToString("yyyyMMdd_HHmmss") ?? "UnknownTime";
var modalitysStr = string.Join('_', study.SeriesList.Select(t => t.Modality).Distinct());
// ---------- DICOMDIR ----------
@ -1172,8 +1172,11 @@ namespace IRaCIS.Core.API.Controllers
}
else
{
await using var source = await _oSSService.GetStreamFromOSSAsync(instance.Path);
await source.CopyToAsync(entryStream, 32 * 1024, abortToken);
await using (var source = await _oSSService.GetStreamFromOSSAsync(instance.Path))
{
await source.CopyToAsync(entryStream, 32 * 1024, abortToken);
}
}

View File

@ -544,31 +544,58 @@ public class OSSService : IOSSService
var pipe = new System.IO.Pipelines.Pipe();
_ = Task.Run(async () =>
{
try
var args = new GetObjectArgs()
.WithBucket(minIOConfig.BucketName)
.WithObject(ossRelativePath)
.WithCallbackStream(async stream => // ✅ 使用异步回调
{
var args = new GetObjectArgs()
.WithBucket(minIOConfig.BucketName)
.WithObject(ossRelativePath)
.WithCallbackStream( stream =>
{
stream.CopyTo(pipe.Writer.AsStream());
});
await minioClient.GetObjectAsync(args);
await pipe.Writer.CompleteAsync();
}
catch (Exception ex)
{
Log.Error($"minio 获取流错误:{ex.Message}");
await pipe.Writer.CompleteAsync(ex);
}
});
try
{
var pipeStream = pipe.Writer.AsStream();
await stream.CopyToAsync(pipeStream); // ✅ 使用异步CopyTo
await pipe.Writer.CompleteAsync();
}
catch (Exception ex)
{
Log.Error($"minio 获取流错误:{ex.Message}");
await pipe.Writer.CompleteAsync(ex);
}
});
await minioClient.GetObjectAsync(args);
return pipe.Reader.AsStream();
#region 废弃2
//var pipe = new System.IO.Pipelines.Pipe();
//_ = Task.Run(async () =>
//{
// try
// {
// var args = new GetObjectArgs()
// .WithBucket(minIOConfig.BucketName)
// .WithObject(ossRelativePath)
// .WithCallbackStream(stream =>
// {
// stream.CopyTo(pipe.Writer.AsStream());
// });
// await minioClient.GetObjectAsync(args);
// await pipe.Writer.CompleteAsync();
// }
// catch (Exception ex)
// {
// Log.Error($"minio 获取流错误:{ex.Message}");
// await pipe.Writer.CompleteAsync(ex);
// }
//});
//return pipe.Reader.AsStream();
#endregion
#region 废弃
//var memoryStream = new MemoryStream();