Angular file explorer after upload a file i need to create a message popup once its reached the max allocated memory

Hello,


I'm using angular file manager and aspnet core web api in a project.

in file manager we are uploading files and validating files and given as response custom message. 

but I am unable to use failure method to capture the response from server


Client side:


onUploadFail(args)

  {

      let response = JSON.parse(args.e.target.response);

      args.statusText = response.message;       

      console.log(response.message);

  }


Server side:


Response.Clear();

Response.ContentType = "application/json; charset=utf-8";

Response.StatusCode = 404; //200

Response.Headers.Add("status","Custom Message");


if I send the statuscode as 404 means it will automatically trigger, file already exists popup, Instead of that I need to show a custom popup message.

kindly share the sample if available.

Thanks in advance

1 Reply 1 reply marked as answer

MK Muthukrishnan Kandasamy Syncfusion Team December 29, 2020 10:14 AM UTC

 
Hi Karthick, 
 
Thanks for contacting Syncfusion support. 
 
We have validated your requirement in File Manager component. We can change the default message for upload fail and also get the custom error message in client side by using failure event in File Manager. Please refer to the below code block. 
 
// uploads the file(s) into a specified path 
        [Route("Upload")] 
        public IActionResult Upload(string path, IList<IFormFile> uploadFiles, string action) 
        { 
            FileManagerResponse uploadResponse; 
            uploadResponse = operation.Upload(path, uploadFiles, action, null); 
            if (uploadResponse.Error != null) 
            { 
               Response.Clear(); 
               Response.ContentType = "application/json; charset=utf-8"; 
               Response.StatusCode = Convert.ToInt32(uploadResponse.Error.Code); 
               Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = "Custom message"; 
            } 
            return Content(""); 
        } 
 
Please make the above changes in the following line with FileManagerController.cs file. 
 
 
<div class="sample-container"> 
  <ejs-filemanager 
    id="filemanager" 
    [ajaxSettings]="ajaxSettings" 
    (failure)="onFail($event)" 
  > 
  </ejs-filemanager> 
</div> 
 
  
 
 
 onFail(args) { 
    console.log(args.error.statusText); 
  } 
 
 
We have prepared sample application for your convenience, please refer to the below link for the sample. 
 
 
The attached ASP.NET Core file provider can be downloaded from the below link. 
 
 
Please check out the below output screenshot of the shared sample. 
 
 
 
 
Please refer to the below links to know more about File Manager component. 
 
 
 
 
Please let us know, if you need any further assistance. 
 
Regards, 
Muthukrishnan K 



Marked as answer
Loader.
Up arrow icon