Download from a URL
Just thought to get your feedback on this.
I am using the following code to create a byte[] from a (video) URL and then your component and it works just splendidly but do you see an issue with it or recommend that I use something else?
private async Task DownloadAsync(string path)
{
using var client = new HttpClient();
using var response = await client.GetAsync(path.Url);
byte[] imageBytes = await response.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
await BlazorDownloadFileService.DownloadFileAsync("Video.mp4", imageBytes);
}
Would you do something else or is this just fine in WASM Blazor-land?
p.s The video files can get pretty large.
e.s Would be great to have a BlazorDownloadFileService.DownloadFileFromUrlAsync() method
In my example application:
https://github.com/StefH/Blazor.YouTubeDownloader/blob/main/Blazor.YouTubeDownloader/Pages/Index.razor.cs
I read a stream form an Azure Function, and just read that stream into a memorystream which is fed to the DownloadFileAsync as a byte-array. However, this means that you need a lot of memory on the client to handle this.
I did not yet investigate if just using a stream would also work.