menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class UploaderEvents - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class UploaderEvents

    Specifies the Uploader Events of the component.

    Inheritance
    System.Object
    UploaderEvents
    Namespace: Syncfusion.Blazor.Inputs
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class UploaderEvents : OwningComponentBase

    Constructors

    UploaderEvents()

    Declaration
    public UploaderEvents()

    Properties

    BeforeRemove

    Gets or sets the event callback that will be invoked before removing the file from the server.

    Declaration
    public EventCallback<BeforeRemoveEventArgs> BeforeRemove { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<BeforeRemoveEventArgs>

    An event callback function.

    BeforeUpload

    Gets or sets the event callback that will be invoked before the uploading process starts.

    Declaration
    public EventCallback<BeforeUploadEventArgs> BeforeUpload { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<BeforeUploadEventArgs>

    An event callback function.

    Remarks

    You can pass additional data with the file uploading request in the CustomFormData argument.

    Examples
    @using Syncfusion.Blazor.Inputs
    <SfUploader>
        <UploaderEvents BeforeUpload="@BeforeUploadHandler"/>
    </SfUploader>
    @code {
    public void BeforeUploadHandler(BeforeUploadEventArgs args) {
       var accessToken = "Authorization_token";
       args.CurrentRequest = new List<object> { new { Authorization = accessToken } };
    }
    }

    Created

    Gets or sets the event callback that will be invoked when the SfUploader component is created.

    Declaration
    public EventCallback<object> Created { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<System.Object>

    An event callback function.

    FileSelected

    Gets or sets the event callback invoked after selecting or dropping the files in the SfUploader.

    Declaration
    public EventCallback<SelectedEventArgs> FileSelected { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<SelectedEventArgs>

    An event callback function.

    OnActionComplete

    Gets or sets the event callback that will be invoked after all the selected files has processed to upload successfully or failed to server.

    Declaration
    public EventCallback<ActionCompleteEventArgs> OnActionComplete { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<ActionCompleteEventArgs>

    An event callback function.

    OnCancel

    Gets or sets the event callback that will be invoked if the chunk file uploading action is canceled.

    Declaration
    public EventCallback<CancelEventArgs> OnCancel { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<CancelEventArgs>

    An event callback function.

    OnChunkFailure

    Gets or sets the event callback that will be invoked if the chunk file fails to upload.

    Declaration
    public EventCallback<FailureEventArgs> OnChunkFailure { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<FailureEventArgs>

    An event callback function.

    OnChunkSuccess

    Gets or sets the event callback that will be invoked when every chunk file is uploaded successfully.

    Declaration
    public EventCallback<SuccessEventArgs> OnChunkSuccess { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<SuccessEventArgs>

    An event callback function.

    OnChunkUploadStart

    Gets or sets the event callback that will be invoked when every chunk upload process gets started.

    Declaration
    public EventCallback<UploadingEventArgs> OnChunkUploadStart { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<UploadingEventArgs>

    An event callback function.

    Remarks

    Pass the additional data with the file uploading request in the CustomFormData argument.

    Examples
    @using Syncfusion.Blazor.Inputs
    <SfUploader ID="UploadFiles">
        <UploaderAsyncSettings SaveUrl="api/SampleData/Save" RemoveUrl="api/SampleData/Remove" ChunkSize="50000" />
        <UploaderEvents OnChunkUploadStart="@ChunkUploadStartHandler" />
    </SfUploader>
    @code {
    public void ChunkUploadStartHandler(UploadingEventArgs args) {
       var accessToken = "Authorization_token";
       args.CurrentRequest = new List<object> { new { Authorization = accessToken } };
    }
    }

    OnClear

    Gets or sets the event callback invoked before clearing the items in the file list using the Clear button.

    Declaration
    public EventCallback<ClearingEventArgs> OnClear { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<ClearingEventArgs>

    An event callback function.

    OnFailure

    Gets or sets the event callback that will be invoked when the file uploading or removal request fails.

    Declaration
    public EventCallback<FailureEventArgs> OnFailure { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<FailureEventArgs>

    An event callback function.

    OnFileListRender

    Gets or sets the event callback invoked before rendering each file item. It helps to customize specific file item structures.

    Declaration
    public EventCallback<FileListRenderingEventArgs> OnFileListRender { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<FileListRenderingEventArgs>

    An event callback function.

    OnRemove

    Gets or sets the event callback invoked on removing the uploaded file.

    Declaration
    public EventCallback<RemovingEventArgs> OnRemove { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<RemovingEventArgs>

    An event callback function.

    Remarks

    This event used to be confirmed before removing the file from the server.

    OnResume

    Fires if resume the paused chunk file upload.

    Declaration
    public EventCallback<PauseResumeEventArgs> OnResume { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<PauseResumeEventArgs>

    An event callback function.

    OnUploadStart

    Gets or sets the event callback invoked when the upload process starts. This event is used to add a parameter to the upload request.

    Declaration
    public EventCallback<UploadingEventArgs> OnUploadStart { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<UploadingEventArgs>

    An event callback function.

    Paused

    Gets or sets the event callback invoked when the chunk file uploading is paused.

    Declaration
    public EventCallback<PauseResumeEventArgs> Paused { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<PauseResumeEventArgs>

    An event callback function.

    Progressing

    Gets or sets the event callback invoked when a file is uploading.

    Declaration
    public EventCallback<ProgressEventArgs> Progressing { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<ProgressEventArgs>

    An event callback function.

    Success

    Gets or sets the event callback invoked when uploading or removing files is successful.

    Declaration
    public EventCallback<SuccessEventArgs> Success { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<SuccessEventArgs>

    An event callback function.

    ValueChange

    Gets or sets the event callback that will be invoked when the collection of the selected files is uploaded for each file.

    Declaration
    public EventCallback<UploadChangeEventArgs> ValueChange { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<UploadChangeEventArgs>

    An event callback function.

    Remarks

    This event is triggered when the user selects a new file in the input file element. To read the contents of the uploaded file, call the OpenReadStream() method of the IBrowserFile interface, which returns a stream that you can use to read the file data.

    Examples
    @using Syncfusion.Blazor.Inputs
    <SfUploader AutoUpload="true">
        <UploaderEvents ValueChange="@OnChange"></UploaderEvents>
    </SfUploader>
    @code{
        private async Task OnChange(UploadChangeEventArgs args)
        {
            try
            {
                foreach (var file in args.Files)
                {
                    var path = @"D:\" + file.FileInfo.Name;
                    FileStream filestream = new FileStream(path, FileMode.Create, FileAccess.Write);
                    await file.File.OpenReadStream(long.MaxValue).CopyToAsync(filestream);
                    filestream.Close();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
      }

    Methods

    ComponentDispose(Boolean)

    Declaration
    protected void ComponentDispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved