Uploaded .zip Files are corrupted
Hey, I've been trying to upload a .zip file using Inputfile, but while the upload completes without a problem, I cannot open the .zip file afterwards. The file size after the upload is identical to the one before, so I'm not sure what the reason could be. Any ideas?
Are you using StreamReader? WASM or Server Blazor?
I see the same thing when using this (I added an MD5 computation across the pipeline to narrow down the corruption to here)
` private async Task DropFile(IFileListEntry[] files) { var file = files.FirstOrDefault(); if (file != null) { status = "Loading...";
byte[] data = new byte[file.Data.Length];
await file.Data.ReadAsync(data, 0, data.Length);
string hash = data.ToMD5();`
Found the solution (or workaround) was to use:
using var ms = new MemoryStream();
await file.Data.CopyToAsync(ms);
var data = ms.ToArray();
Instead of:
//byte[] data = new byte[file.Data.Length];
//await file.Data.ReadAsync(data, 0, data.Length);