Hello All,
I’m writing a Blazor WASM app that uploads videos to my server, I have tested it via postman and it works. However, on the OnChange handler when I attempt to convert my file from the file picker to a bytearray by copying the contents to the MemoryStream I get a weird error:
System.IO.IOException: Supplied file with size 166884574 bytes exceeds the maximum of 512000 bytes.
I know that means my file is to big and it happens when trying to CopyToAsync to my MemoryStream,
so my question is how do I convert a large file to byte [] without throwing that exception or how do I change the maximum byte size allowed? I use the same code on my server (MemoryStream) and I don’t get this exception there so why is it only giving it to me in Blazor WASM Client?
WASM only has so much memory, it is just too big fit entirely in memory. You aren’t gonna be able to load the entire thing into memory. I’m not sure exactly what you are trying to do. For something like this you would normally load a chunk at a time, process it and then write the result, unload it and load the next chunk. I don’t know if that is possible for whatever you are trying, but that is the process you’d have to go through.
So in theory if I created a Blazor server app and used .razor components it would work since it’s SSR vs WASM?
Also i’m trying to send the video file to my .net api that accepts IFormFile file as it’s parameter, if I were to send it a chunk at a time do you have any good resources that would allow me to accept it in chunks and then combine it all as one file on the .net server?
C# devs
null reference exceptions