> For the complete documentation index, see [llms.txt](https://docs.appmixer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appmixer.com/connector-configuration/utils/files/download-file.md).

# Download File

### Overview

The **Download File Component** allows users to download a file from a given link and store it in the system. It supports specifying a custom filename for the downloaded file.

### Usage

This component is used to retrieve files from remote URLs and save them for further processing in workflows.

#### Properties

| Property         | Type     | Description                                                                                    |
| ---------------- | -------- | ---------------------------------------------------------------------------------------------- |
| `link`           | `string` | The URL of the file to download.                                                               |
| `customFileName` | `string` | Optional. The custom name for the downloaded file, including its extension (e.g., `file.png`). |

#### Input Ports

| Port | Description                                        |
| ---- | -------------------------------------------------- |
| `in` | Accepts the file URL and optional custom filename. |

#### Output Ports

| Port  | Description                                                                          |
| ----- | ------------------------------------------------------------------------------------ |
| `out` | Emits the downloaded file's metadata, including file ID, filename, and content type. |

#### Processing Logic

1. **Receives Input Data**:
   * Accepts a `link` to a file and an optional `customFileName`.
2. **Validates URL**:
   * Checks if the provided `link` is a valid URL.
   * If invalid, throws an error.
3. **Downloads the File**:
   * Sends an HTTP request to retrieve the file.
   * Extracts the filename from the response headers or URL if no custom filename is provided.
4. **Saves the File**:
   * Stores the file and generates a unique `fileId`.
5. **Handles Success & Errors**:
   * If successful, sends the downloaded file's details to the `out` port.
   * If an error occurs (e.g., invalid URL or download failure), it is logged or raised appropriately.

#### Output Data Schema

| Property      | Type     | Description                                   |
| ------------- | -------- | --------------------------------------------- |
| `fileId`      | `string` | The unique identifier of the downloaded file. |
| `filename`    | `string` | The name of the downloaded file.              |
| `contentType` | `string` | The MIME type of the downloaded file.         |

### Notes

* **Validates URLs Before Downloading**: Ensures the provided `link` is a valid file URL.
* **Supports Custom Filenames**: Users can specify a filename or rely on the original filename from the response.
* **Ideal for Automated File Retrieval**: Useful in workflows that require downloading and storing remote files.

This component is essential for workflows that need to automate file downloads from external sources for further processing.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.appmixer.com/connector-configuration/utils/files/download-file.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
