Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Pass large JS blob to Blazor byte[]

$
0
0

I need to record some audio, maybe even video, using Media API in JS, example for Blazor. Then, I would like to pass recorded Blob content from JS to Blazor. As far as this is audio or video content, it can be pretty big.

What I have tried so far

  1. Encoding data as ANSI string or passing an array of integers. This results in InvalidDataException, SignalR disconnect, timeout, after a minute or so SignalR gets back to life and C# receives null

  2. Encoding data as base 64 or passing UInt8Array. Outcome is the same.

  3. Passing Blob, ArrayBuffer, or FormData directly from JS. This results in empty object ValueKind: {} in C#.

The source of JS call

recorder.stop();recorder.exportWAV(async blob => {  const content = await (new Response(blob).arrayBuffer());  const contentNums = new Uint8Array(content);  const contentCodes = new TextDecoder('windows-1252').decode(contentNums);  const data = new FormData();  data.append('file', blob, 'Demo');  //success(window.URL.createObjectURL(blob));  console.log(blob)  console.log(content)  console.log(contentNums)  console.log(contentCodes)  success(Array.from(contentNums));})

The source of C# interop call

private IJSRuntime _scriptRuntime = null;public async Task<dynamic> GetMedia<dynamic>(){  return await _scriptRuntime.InvokeAsync<dynamic>('AudioFunctions.GetMediaFile');}

Is there a way to pass large byte arrays or at least strings from JS to Blazor.NET?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>