I figured out one way to do it. I converted my Blob to a base64 string.
//JavaScript to convert Blob to base64 string
const blobToBase64 = blob => {
const reader = new FileReader();
reader.readAsDataURL(blob);
return new Promise(resolve => {
reader.onloadend = () => {
resolve(reader.result.substr(reader.result.indexOf(',') + 1));
};
});
};
Then passed the base64 string in as a parameter of type byte array as shown below.
// My C# method in my Blazor app
[JSInvokable("UploadFile")]
public async Task UploadFile(byte[] recording)
{
MemoryStream e = new MemoryStream(recording);
var path = $"{env.WebRootPath}\\uploads\\file.ogg";
FileStream fs = File.Create(path);
await e.CopyToAsync(fs);
e.Close();
fs.Close();
}