Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

745
Visualizações
BlazorInputFile - Synchronous reads are not supported

I am trying to use SteveSanderson's BlazorInputFile package to upload files in a Blazor WASM app. (Server/Client setup). I installed the package according to the instructions on his blog post.

My api takes in the file in a byte[] so I am converting the file from a Stream to byte[], and then posting to my API endpoint in the Server.

private async Task Upload(InputFileChangeEventArgs e)
{
    MemoryStream ms = new MemoryStream();
    e.File.OpenReadStream().CopyTo(ms);
    var bytes = ms.ToArray();
    UploadFile file = new UploadFile
    {
        FileName = e.File.Name,
        FileContent = bytes,
        Size = e.File.Size,
        ContentType = e.File.ContentType
    };
        await Http.PostAsJsonAsync<UploadFile>("/api/uploadfile", file);
        await OnInitializedAsync();
}

Unfortunately I keep getting an error/exception from BlazorInputFile which says "Synchronous reads are not supported".

I have tried to search the error and had various fixes (Browser adblocker could be blocking etc) but not of them has fixed the problem.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Looks like the issue is you are using the synchronous version of Stream.CopyTo Method which is the reason you are getting the error message about synchronous reads not being supported. I believe changing that line to:

await e.File.OpenReadStream().CopyToAsync(ms);

Will most likely solve your issue.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda