Docs_MyUploaderState.razor

1. About MyUploaderState

MyUploaderState is an open source class in project file '/MyUploaderState.cs'.

It's a default template for demonstrating how to process the file event and stream.

It stores the primary server states.

2. Create an instance

In the demo code, it's created like this: (/Demo/Demo_SimpleButton.razor)

@code {

    MyUploaderState upstate = new MyUploaderState();

    protected override void OnInitialized()

    {

        base.OnInitialized();

        upstate.StateHasChanged += StateHasChanged;

    }

}

3. Attach to CoreUploader

By handling the FilesAdded and FilesError event: (/Demo/Demo_SimpleButton.razor)

<BlazorUploader.CoreUploader FilesAdded="upstate.HandleFilesAdded" FilesError="upstate.HandleFilesError">

    <button class="btn btn-primary">Browse a file</button>

</BlazorUploader.CoreUploader>

The HandleFilesAdded and HandleFilesError will add selected files to MyUploaderState.AllFiles and MyUploaderState.ErrFiles.

In this demo application, when FilesAdded occurs, HandleFilesAdded will run MyUploaderState.ProcessFilesAsync() and read file data and save to Program.UploadDemoTempDir.

Developer can modify MyUploaderState.ProcessFilesAsync() and save the file data to anywhere they want.

An error has occurred. This application may no longer respond until reloaded. Reload 🗙