Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Uploaded .zip Files are corrupted #35

Open
agoodnap opened this issue May 14, 2020 · 3 comments
Open

Uploaded .zip Files are corrupted #35

agoodnap opened this issue May 14, 2020 · 3 comments

Comments

@agoodnap
Copy link

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?

@TotzkePaul
Copy link

Are you using StreamReader? WASM or Server Blazor?

@devnu11
Copy link

devnu11 commented Sep 10, 2020

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();`

@devnu11
Copy link

devnu11 commented Sep 10, 2020

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);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants