Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
17 changes: 12 additions & 5 deletions src/BootstrapBlazor/Components/Download/Download.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone

using System;

namespace BootstrapBlazor.Components;

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

#if NET5_0
// net 5.0 not support
await Task.CompletedTask;
#elif NET6_0_OR_GREATER
if (string.IsNullOrEmpty(option.FileName))
{
throw new InvalidOperationException($"the {nameof(option.FileName)} is null or empty");
}

using var streamRef = new DotNetStreamReference(option.FileStream);
await InvokeVoidAsync("downloadFileFromStream", option.FileName, streamRef);
#endif
}

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

if (string.IsNullOrEmpty(option.FileName))
{
throw new InvalidOperationException($"the {nameof(option.FileName)} is null or empty");
}

await InvokeVoidAsync("downloadFileFromUrl", option.FileName, option.Url);
}

Expand Down
Loading