obsolete webclient replaced with httpclient

This commit is contained in:
Kerry Cao 2025-01-28 21:42:12 -05:00
parent 644c41df90
commit 1c03587cd8
2 changed files with 6 additions and 9 deletions

View file

@ -30,21 +30,21 @@ public class FFMpegDownloader
// download ffmpeg if selected
if (binaries.HasFlag(FFMpegBinaries.FFMpeg) && downloadInfo.FFMpeg is not null)
{
var zipStream = FFbinariesService.DownloadFileAsSteam(new Uri(downloadInfo.FFMpeg));
await using var zipStream = await FFbinariesService.DownloadFileAsSteam(new Uri(downloadInfo.FFMpeg));
successList.AddRange(FFbinariesService.ExtractZipAndSave(zipStream));
}
// download ffprobe if selected
if (binaries.HasFlag(FFMpegBinaries.FFProbe) && downloadInfo.FFProbe is not null)
{
var zipStream = FFbinariesService.DownloadFileAsSteam(new Uri(downloadInfo.FFProbe));
await using var zipStream = await FFbinariesService.DownloadFileAsSteam(new Uri(downloadInfo.FFProbe));
successList.AddRange(FFbinariesService.ExtractZipAndSave(zipStream));
}
// download ffplay if selected
if (binaries.HasFlag(FFMpegBinaries.FFPlay) && downloadInfo.FFPlay is not null)
{
var zipStream = FFbinariesService.DownloadFileAsSteam(new Uri(downloadInfo.FFPlay));
await using var zipStream = await FFbinariesService.DownloadFileAsSteam(new Uri(downloadInfo.FFPlay));
successList.AddRange(FFbinariesService.ExtractZipAndSave(zipStream));
}

View file

@ -43,13 +43,10 @@ internal class FFbinariesService
/// </summary>
/// <param name="address">uri of the file</param>
/// <returns></returns>
internal static MemoryStream DownloadFileAsSteam(Uri address)
internal static async Task<Stream> DownloadFileAsSteam(Uri address)
{
var client = new WebClient();
var fileStream = new MemoryStream(client.DownloadData(address));
fileStream.Position = 0;
return fileStream;
var client = new HttpClient();
return await client.GetStreamAsync(address);
}
/// <summary>