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

Cannot access file data #66

Open
ckorn opened this issue Mar 7, 2021 · 0 comments
Open

Cannot access file data #66

ckorn opened this issue Mar 7, 2021 · 0 comments

Comments

@ckorn
Copy link

ckorn commented Mar 7, 2021

Hi,

when choosing a file, I can see the file details. But reading the file just does not work.
I do not know what excactly does not work. There is no exception.
When trying this code in VisualStudio the process (not Visual Studio but the started process) crashes.

On my deployed machine this does not happen but it does not work anyway.

This is my code:

<BlazorInputFile.InputFile OnChange="HandleFileSelected" MaxMessageSize="99999999" />
@if (file != null)
{
<p>Name: @file.Name</p>
<p>Size in bytes: @file.Size</p>
<p>Last modified date: @file.LastModified.ToShortDateString()</p>
<p>Content type (not always supplied by the browser): @file.Type</p>
}

<p>@status</p>
@code {
    IFileListEntry file;
    string status;

    async Task HandleFileSelected(IFileListEntry[] files)
    {
        file = files.FirstOrDefault();
        if (file != null)
        {
            // Just load into .NET memory to show it can be done
            // Alternatively it could be saved to disk, or parsed in memory, or similar
            var ms = new MemoryStream();
            await file.Data.CopyToAsync(ms);

            status = $"Finished loading {file.Size} bytes from {file.Name}";
        }
    }
}

I can see the first part with the filename and file size (96353 bytes).
But the status is never shown.

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

1 participant