# Downloader

## Overview

The `Downloader` class is used internally and provided to users as a convenient mechanism for pre-caching audio located at a URL.

The `Downloader` class can actually be used to download any resource.

The `Downloader` class downloads the URL and saves it into a local file.

It is your responsibility to delete the local file once you have finished with it.

```dart
var saveToFile = TempMediaFile().empty();

await Downloader.download('https://some/path/rock.aac', saveToFile);

var track = Track.fromPath(saveToFile);
...
FileUtil().delete(saveToFile);
```

You can also obtain download progress information.

```dart
var saveToFile = TempMediaFile().empty();

await Downloader.download('https://some/path/rock.aac', saveToFile, progress:   (disposition) {
        print('progress ${disposition.state}, ${disposition.progress}';
    });
```


---

# 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://bsutton.gitbook.io/sounds/api/downloader.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.
