Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/BootstrapBlazor/Components/Upload/ButtonUploadBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ protected override async Task OnFileChange(InputFileChangeEventArgs args)
OriginFileName = f.Name,
Size = f.Size,
File = f,
FileCount = args.FileCount,
Uploaded = OnChange == null,
UpdateCallback = Update
}).ToList();
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/Upload/UploadBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public abstract class UploadBase<TValue> : ValidateBase<TValue>, IUpload
.Build();

/// <summary>
///
/// 获得/设置 当前上传文件
/// </summary>
protected UploadFile? CurrentFile { get; set; }

Expand Down
5 changes: 5 additions & 0 deletions src/BootstrapBlazor/Components/Upload/UploadFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public class UploadFile
/// </summary>
public IBrowserFile? File { get; set; }

/// <summary>
/// 获得/设置 上传文件数量
/// </summary>
public int FileCount { get; init; } = 1;

/// <summary>
/// 获得/设置 更新进度回调委托
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions test/UnitTest/Components/UploadTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,13 +606,15 @@ await cut.InvokeAsync(async () =>
[Fact]
public async Task ButtonUpload_IsDirectory_Ok()
{
var fileCount = 0;
var fileNames = new List<string>();
List<UploadFile> fileList = [];
var cut = Context.RenderComponent<ButtonUpload<string>>(pb =>
{
pb.Add(a => a.IsDirectory, true);
pb.Add(a => a.OnChange, file =>
{
fileCount = file.FileCount;
fileNames.Add(file.OriginFileName!);
return Task.CompletedTask;
});
Expand All @@ -628,6 +630,7 @@ await cut.InvokeAsync(() => input.Instance.OnChange.InvokeAsync(new InputFileCha
new(),
new("UploadTestFile2")
})));
Assert.Equal(2, fileCount);
Assert.Equal(2, fileNames.Count);
Assert.Equal(2, fileList.Count);
}
Expand Down