# wire.download

This method allows a file to be downloaded from a web service.  It creates an `XMLHttpRequest` object and makes the call using the parameters listed below.

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

## Parameters

| Name         | Default  | Description                                                                                        |
| ------------ | -------- | -------------------------------------------------------------------------------------------------- |
| contentType  |          | This value is added to the request header `Content-Type` if supplied.                              |
| data         |          | Sends data in the body of the message. Note, this changes the call from an HTTP *GET* to a *POST*. |
|              |          | Callback                                                                                           |
| fileName     | file.txt | The name of the file to be downloaded.                                                             |
| responseType | blob     | Sets the `responseType` on the request.                                                            |
| url          |          | The web service end point from which the file will be downloaded.                                  |

### Events

The following callbacks can be configured.

| Name                         | Description                                                                    |
| ---------------------------- | ------------------------------------------------------------------------------ |
| done(HttpRequest)            | Function that is called when the download has finished successfully.           |
| fail(exception, HttpRequest) | Function that is called if the download fails.                                 |
| finally(HttpRequest)         | Function that is called when the download has finished  in success or failure. |


---

# 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/reference/wire/wire.download.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.
