Skip to content

Commit b035658

Browse files
authored
feat(Download): add FileName check (dotnetcore#6568)
1 parent 3ddbf27 commit b035658

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/BootstrapBlazor/Components/Download/Download.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
55

6+
using System;
7+
68
namespace BootstrapBlazor.Components;
79

810
/// <summary>
@@ -38,13 +40,13 @@ protected virtual async Task DownloadFromStream(DownloadOption option)
3840
throw new InvalidOperationException($"the {nameof(option.FileStream)} is null");
3941
}
4042

41-
#if NET5_0
42-
// net 5.0 not support
43-
await Task.CompletedTask;
44-
#elif NET6_0_OR_GREATER
43+
if (string.IsNullOrEmpty(option.FileName))
44+
{
45+
throw new InvalidOperationException($"the {nameof(option.FileName)} is null or empty");
46+
}
47+
4548
using var streamRef = new DotNetStreamReference(option.FileStream);
4649
await InvokeVoidAsync("downloadFileFromStream", option.FileName, streamRef);
47-
#endif
4850
}
4951

5052
/// <summary>
@@ -59,6 +61,11 @@ protected virtual async Task DownloadFromUrl(DownloadOption option)
5961
throw new InvalidOperationException($"{nameof(option.Url)} not set");
6062
}
6163

64+
if (string.IsNullOrEmpty(option.FileName))
65+
{
66+
throw new InvalidOperationException($"the {nameof(option.FileName)} is null or empty");
67+
}
68+
6269
await InvokeVoidAsync("downloadFileFromUrl", option.FileName, option.Url);
6370
}
6471

0 commit comments

Comments
 (0)