How to customize response message in Blazor File Uploader?

Answer:

We can customize the success and failure messages in the success and failure event. Also, We can pass the custom status messages in the response header and get the passed data in the success event arguments form args.Response.Headers. We can do the same for the failure event also. Kindly refer the below code example,

public void OnSuccess(SuccessEventArgs args)
{
args.StatusText = "File upload Success";
//Also, you can send the status from the server in header and receive in the success event
var customHeader = args.Response.Headers.Split(new Char[] { '' })[3]; // To split the response header values
var key = customHeader.Split(new Char[] { ':' })[0]; // To get the key pair of provided custom data in header
var value = customHeader.Split(new Char[] { ':' })[1].Trim(); // To get the value for the key pair of provided custom data in header
}
public void onFailure(FailureEventArgs args)
{
args.StatusText = "File upload failed";
}

[Controller]
Response.Headers.Add("ID", "Failure"); // Assign the custom data in the response header.


Find the sample for customizing response messages in Blazor File Uploader from here.

Loader.
Up arrow icon