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(); 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()); var modalitysStr = string.Join('_', study.SeriesList.Select(t => t.Modality).Distinct());
// ---------- DICOMDIR ---------- // ---------- DICOMDIR ----------
@ -1172,8 +1172,11 @@ namespace IRaCIS.Core.API.Controllers
} }
else else
{ {
await using var source = await _oSSService.GetStreamFromOSSAsync(instance.Path); await using (var source = await _oSSService.GetStreamFromOSSAsync(instance.Path))
await source.CopyToAsync(entryStream, 32 * 1024, abortToken); {
await source.CopyToAsync(entryStream, 32 * 1024, abortToken);
}
} }

View File

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