C
C#10mo ago
Lexan

Download audio file from blob

Hello! I'm trying to download an audio file from an open unsecured blob with a URL that starts with blob:https. I'm working on an ASP.NET Core app, .net 7, and Windows both locally and on the host in Azure. WebClient can't handle the blob prefix. Does anyone have another approach to how to download the file or get the stream?
4 Replies
Angius
Angius10mo ago
WebClient is deprecated btw, it shouldn't be used for anything, not just file download Try HttpClient If it's a stream, then something like
using var ms = new MemoryStream();
using var client = new HttpClient();

var res = await client.GetStreamAsync(url);
res.CopyTo(ms);
using var ms = new MemoryStream();
using var client = new HttpClient();

var res = await client.GetStreamAsync(url);
res.CopyTo(ms);
should do
Lexan
LexanOP10mo ago
I see. That is very good info. I should look at updating the code then. However, it is the same problem with HttpClient. I saying that the 'blob' scheme is not supported. Btw how did you get the code to look like that in discord?
SinFluxx
SinFluxx10mo ago
$codegif
Want results from more Discord servers?
Add your server