# Download Files

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.

```javascript
wire.download({
    url: "/download-file",
    fileName: "sales_oct.pdf"
});
```

Add parameters to the call if needed.

```javascript
wire.download({
    url: "/DownloadFile?month=10",
    fileName: "sales_oct.pdf"
});
```

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.

```javascript
const payload = { month: 10 };

wire.download({
    url: "/DownloadFile",
    data: payload,    
    fileName: "sales_oct.pdf"
});
```

Below is a *C#* example of what the service method might look like for this call.

```csharp
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);
        }
    }
}
```

For a complete list of download options, visit the [wire.download](/wirebootstrap/reference/wire/wire.download.md) reference page.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wirebootstrap.com/wirebootstrap/utilities/download-files.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
