Class BeforeUploadEventArgs
Provides information about the BeforeUpload event callback.
Inheritance
Namespace: Syncfusion.Blazor.Inputs
Assembly: Syncfusion.Blazor.dll
Syntax
public class BeforeUploadEventArgs : Object
Remarks
This event is triggered before files are uploaded to the server. It provides an opportunity to cancel the upload operation, modify request parameters, add authentication headers, or perform validation before the actual upload process begins.
Constructors
BeforeUploadEventArgs()
Declaration
public BeforeUploadEventArgs()
Properties
Cancel
Gets or sets a value indicating whether the file upload action has been canceled.
Declaration
public bool Cancel { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
Setting this property to true
will prevent the file upload operation from proceeding.
This allows for conditional uploads based on file validation, user permissions, or other custom logic.
CurrentRequest
Gets or sets the XMLHttpRequest instance associated with the file upload operation.
Declaration
public object CurrentRequest { get; set; }
Property Value
Type | Description |
---|---|
System.Object | An object containing XMLHttpRequest details, or |
Remarks
This property provides access to the underlying HTTP request object that will be used for the file upload operation. It allows for customization of request headers, progress monitoring, and other HTTP-specific settings before the upload request is sent to the server.
CustomFormData
Gets or sets additional custom data in key-value pair format to be sent with the file upload request.
Declaration
public object CustomFormData { get; set; }
Property Value
Type | Description |
---|---|
System.Object | An object containing key-value pairs of additional data, or |
Remarks
This property allows developers to include additional parameters or metadata with the file upload request. Common uses include authentication tokens, user identifiers, or other application-specific data required by the server-side upload handler.
Examples
The following example shows how to add authorization headers to the upload request:
<SfUploader>
<UploaderEvents BeforeUpload="@BeforeUploadHandler"/>
</SfUploader>
@code {
public void BeforeUploadHandler(BeforeUploadEventArgs args) {
var accessToken = "Authorization_token";
args.CurrentRequest = new List<object> { new { Authorization = accessToken } };
}
}
FilesData
Gets or sets the list of selected file details that will be uploaded.
Declaration
public List<FileInfo> FilesData { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<FileInfo> | A System.Collections.Generic.List<> containing the details of files to be uploaded, or |
Remarks
This property contains information about all files that are scheduled for upload, including file names, sizes, types, and other metadata. This information can be used for validation, progress tracking, or preprocessing before the upload begins.
WithCredentials
Gets or sets a value indicating whether requests should include credentials for cross-origin requests.
Declaration
public bool WithCredentials { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
When set to true
, the upload request will include credentials such as cookies, authorization headers,
and client certificates for cross-origin requests. This is essential for authenticated uploads when the
upload endpoint is on a different domain than the client application.