Skip to content

Commit a0ad391

Browse files
committed
feat: 增加 BufferSize 参数
1 parent 1c39933 commit a0ad391

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/BootstrapBlazor/Extensions/UploadFileExtensions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ public static async Task RequestBase64ImageFileAsync(this UploadFile upload, str
5757
/// <param name="upload"></param>
5858
/// <param name="fileName"></param>
5959
/// <param name="maxAllowedSize"></param>
60+
/// <param name="bufferSize"></param>
6061
/// <param name="token"></param>
6162
/// <returns></returns>
6263
[ExcludeFromCodeCoverage]
63-
public static async Task<bool> SaveToFileAsync(this UploadFile upload, string fileName, long maxAllowedSize = 512000, CancellationToken token = default)
64+
public static async Task<bool> SaveToFileAsync(this UploadFile upload, string fileName, long maxAllowedSize = 512000, int bufferSize = 64 * 1024, CancellationToken token = default)
6465
{
6566
var ret = false;
6667
if (upload.File != null)
@@ -92,7 +93,7 @@ public static async Task<bool> SaveToFileAsync(this UploadFile upload, string fi
9293
{
9394
// 打开文件流
9495
var stream = upload.File.OpenReadStream(maxAllowedSize, token);
95-
var buffer = new byte[4 * 1096];
96+
var buffer = new byte[bufferSize];
9697
int bytesRead = 0;
9798
double totalRead = 0;
9899

0 commit comments

Comments
 (0)