perf: 使用 FileStreamResult 流式返回文件,避免一次性读取到内存
改为 FileStream 并返回 FileStreamResult,减小内存占用并支持大型文件;修正变量名拼写并添加 null-forgiving 标记。
This commit is contained in:
@@ -43,8 +43,9 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
{
|
||||
return new NotFoundResult();
|
||||
}
|
||||
var steam = await File.ReadAllBytesAsync(path);
|
||||
return new FileContentResult(steam, file.GetMimeMapping());
|
||||
|
||||
var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
return new FileStreamResult(stream, file!.GetMimeMapping());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user