diff --git a/ej2-asp-core-mvc/uploader/EJ2_ASP.MVC/async.md b/ej2-asp-core-mvc/uploader/EJ2_ASP.MVC/async.md index 9e5f999ebc..baae05bd70 100644 --- a/ej2-asp-core-mvc/uploader/EJ2_ASP.MVC/async.md +++ b/ej2-asp-core-mvc/uploader/EJ2_ASP.MVC/async.md @@ -167,6 +167,69 @@ public void Save() } ``` +### Server-side configure save action to returned response + +The following example demonstrates how the server-side action for saving the file in server to returned response in JSON, String and file type data's. + +```c# +[AcceptVerbs("Post")] +public ActionResult Save() +{ + // for JSON Data + try + { + // Process uploaded data + var responseData = new + { + Success = true, + Message = "Files uploaded successfully", + // Additional data can be added here + }; + + return Json(responseData); + } + catch (Exception e) + { + var errorResponse = new + { + Success = false, + Message = "File upload failed: " + e.Message + }; + + return Json(errorResponse); + } + + // for String Data + try + { + // Process string data + var data = "success"; + // Return the string data + return Content(data); + } + catch (Exception) + { + var data = "failed"; + return Content(data); + } + + // for File Data + try + { + // Example: Retrieve file path for stream.txt + var filePath = "/stream.txt"; // Example file path + + // Return the file + return File(filePath, "text/plain"); + } + catch (Exception e) + { + return Content("Failed to retrieve file response: " + e.Message, "text/plain"); + } +} + +``` + ## Remove action The remove action is optional. Specify the URL to handle remove process from server. @@ -302,9 +365,9 @@ By default, the uploader control process multiple files to upload simultaneously -## Preload files +## Preloaded files -The uploader control allows you to preload the list of files that are uploaded in the server. The preloaded files are useful to view and remove the files from server that can be achieved by the [files](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Inputs.Uploader.html#Syncfusion_EJ2_Inputs_Uploader_Files) property. By default, the files are configured with uploaded successfully state on rendering file list. The following properties are mandatory to configure the preloaded files: +The uploader control allows you to preloaded the list of files that are uploaded in the server. The preloaded files are useful to view and remove the files from server that can be achieved by the [files](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Inputs.Uploader.html#Syncfusion_EJ2_Inputs_Uploader_Files) property. By default, the files are configured with uploaded successfully state on rendering file list. The following properties are mandatory to configure the preloaded files: * Name * Size diff --git a/ej2-asp-core-mvc/uploader/EJ2_ASP.NETCORE/async.md b/ej2-asp-core-mvc/uploader/EJ2_ASP.NETCORE/async.md index 595c61ff56..15ba66d575 100644 --- a/ej2-asp-core-mvc/uploader/EJ2_ASP.NETCORE/async.md +++ b/ej2-asp-core-mvc/uploader/EJ2_ASP.NETCORE/async.md @@ -202,6 +202,73 @@ public void Save(IList chunkFile, IList UploadFiles) ``` +### Server-side configure save action to returned response + +The following example demonstrates how the server-side action for saving the file in server to returned response in JSON, String and File type data's. + +```c# +[AcceptVerbs("Post")] +public IActionResult Save() +{ + // for JSON Data + try + { + // Process uploaded data + var responseData = new + { + Success = true, + Message = "Files uploaded successfully", + // Additional data can be added here + }; + + return Json(responseData); + } + catch (Exception e) + { + var errorResponse = new + { + Success = false, + Message = "File upload failed: " + e.Message + }; + + return Json(errorResponse); + } + + // for String Data + try + { + // Process string data + var data = "success"; + // Return the string data + return Content(data); + } + catch (Exception) + { + var data = "failed"; + return Content(data); + } + + // for File Data + try + { + // Example: Retrieve file path for stream.txt + var filePath = "stream.txt"; // Example file path + + // Get full file path + var fullPath = Path.GetFullPath(filePath); + + // Return the file + return PhysicalFile(fullPath, "text/plain"); + } + catch (Exception e) + { + // Handle file retrieval failure + return Content("Failed to retrieve file response: " + e.Message, "text/plain"); + } +} + +``` + ## Remove action The remove action is optional. Specify the URL to handle remove process from server. @@ -393,9 +460,9 @@ By default, the uploader control process multiple files to upload simultaneously -## Preload files +## Preloaded files -The uploader control allows you to preload the list of files that are uploaded in the server. The preloaded files are useful to view and remove the files from server that can be achieved by the [files](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Inputs.Uploader.html#Syncfusion_EJ2_Inputs_Uploader_Files) property. By default, the files are configured with uploaded successfully state on rendering file list. The following properties are mandatory to configure the preloaded files: +The uploader control allows you to preloaded the list of files that are uploaded in the server. The preloaded files are useful to view and remove the files from server that can be achieved by the [files](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Inputs.Uploader.html#Syncfusion_EJ2_Inputs_Uploader_Files) property. By default, the files are configured with uploaded successfully state on rendering file list. The following properties are mandatory to configure the preloaded files: * Name * Size