BlazorInputFile icon indicating copy to clipboard operation
BlazorInputFile copied to clipboard

CopyToAsync hangs in provided sample project

Open sgerendasy opened this issue 5 years ago • 4 comments

In the usage information blog post there is an example of a multiple file upload with this source code. In the blog post there is a gif demonstration which shows three files being asynchronously copied to a MemoryStream.

If you begin each copy to MemoryStream before any other files finish copying, this process works fine. However, if you call await file.Data.CopyToAsync(ms) after any other file has finished copying to MemoryStream, the copy hangs after getting ~500kB copied.

You can verify this by cloning the repo and running the sample program with the MultiFile.razor page. Select two or more files to upload, then click the Load button on one of them. Wait until that file is 100% loaded. Then click Load on another file. It will hang.

This is a problem for me because I have a form where 3 different files get selected, using 3 different <InputFile> components. The files begin uploading as soon as their selected, which involves reading the Stream in file.Data. If the user selects a 2nd or 3rd file after a file has finished uploading the newly selected file fails to upload. The program simply hangs.

I have been using files that are 3-50MB in size, which is what I expect the file size range to be in production.

sgerendasy avatar May 05 '20 00:05 sgerendasy

I am experiencing the same issue with just 1 <InputFile>. with a 1MB file the CopyToAsync hangs for around 3-5 seconds.

paulallington avatar May 05 '20 17:05 paulallington

Confirm. it hangs when i press another upload after all previous uploads have finished. image

Boglen avatar May 06 '20 01:05 Boglen

do a ms.Dispose() as last statement

RealHabix avatar May 11 '20 09:05 RealHabix

Thank you @RealHabix, ms.Dispose() did the trick.

sgerendasy avatar May 11 '20 14:05 sgerendasy