WireBootstrap 's wire.download functions handles all the internal details needed to support downloading files from an API call.
The following example makes an HTTP GET call to download a file from a data service at the location specified in the url property in the configuration. The downloaded file name is specified using the fileName property.
To change the call to a POST call in order to send data to the data service in the body of the request before the file is downloaded, add the data property in the configuration and include the data as seen below.
using Microsoft.AspNetCore.Mvc;
public class DownloadController : Controller {
[HttpGet]
public async Task<IActionResult> DownloadFile(int month)
{
try
{
// Get sales report data in bytes for month = 10 (October)
byte[] pdfFile = GetReport(month);
// Return the file to the caller
return File(pdfFile, "application/pdf");
}
catch (Exception ex)
{
return Json(ex);
}
}
}