I have a Blazor Server app, that's acting as a Teams App. The problem is that I can't read files uploaded through this component:
<InputFile class="form-control mb-4" OnChange="@OnInputFileChange" multiple />These versions of OnInputFileChange:
private async Task OnInputFileChange(InputFileChangeEventArgs e){ IBrowserFile fi = e.File; MemoryStream stream = new MemoryStream(); await fi.OpenReadStream(fi.Size).CopyToAsync(stream);}private async Task OnInputFileChange(InputFileChangeEventArgs e){ await using FileStream fs = new(path, FileMode.Create); await browserFile.OpenReadStream().CopyToAsync(fs);}is just one of many iterations, but the issue is always the same:
No bytes or data can be read from the file and it always fails to read the stream and thereby fails to copy to another stream. I get the files metadata, but cannot read from it.
I have tried to increase the message size in program.cs: (The file I am uploading is 8KB)
builder.Services.AddSignalR(options => { options.EnableDetailedErrors = true; options.MaximumReceiveMessageSize = 102400000; // 100 MB });I have tried to make a hub and do this:
app.MapHub<FileUploadHub>("/fileUploadHub", options => { options.ApplicationMaxBufferSize = 102400000; // 100 MB options.TransportMaxBufferSize = 102400000; // 100 MB options.LongPolling.PollTimeout = TimeSpan.FromSeconds(30); });Each time I create a new stream I also get this:
ReadTimeout = 'stream.ReadTimeout' threw an exception of type 'System.InvalidOperationException'WriteTimeout = 'stream.WriteTimeout' threw an exception of type 'System.InvalidOperationException'Be it MemoryStream or Another kind of stream. I cannot open a stream and read data.
I have done a similar thing in Blazor WebAssembly without issue, so I suspect Blazor Server App.