> For the complete documentation index, see [llms.txt](https://docs.datajet-app.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datajet-app.com/liquid/tags/ftp_download.md).

# ftp\_download

Downloads a file from the FTP/SFTP server and stores it in DataJet storage. Must be used inside an `ftp_session` block.

```liquid
{% ftp_session host: "ftp.example.com", user: "myuser", password: "mypass" %}
  {% ftp_download from: "/exports/data.csv" as result %}

  {% if result.ok %}
    {% log "Downloaded: " %}
    {% log result.file.name %}
  {% endif %}
{% endftp_session %}
```

#### Syntax

```liquid
{% ftp_download from: "/path/to/file" as result_variable %}
```

#### Parameters

| Parameter | Required | Description                                                |
| --------- | -------- | ---------------------------------------------------------- |
| `from`    | Yes      | Path to the file on the FTP server                         |
| `public`  | No       | Set to `true` to make the file publicly accessible via URL |

#### Result Object

| Property      | Type        | Description                                         |
| ------------- | ----------- | --------------------------------------------------- |
| `ok`          | boolean     | `true` if download succeeded                        |
| `error`       | string/null | Error message if `ok` is `false`, `null` on success |
| `file.name`   | string      | Name of the downloaded file                         |
| `file.public` | boolean     | Whether the file is publicly accessible             |
| `file.url`    | string      | Public URL (only present if `public: true`)         |

Example result:

```json
{
  "ok": true,
  "error": null,
  "file": {
    "name": "data.csv",
    "public": false
  }
}
```

#### Examples

**Basic download:**

```liquid
{% ftp_session host: FTP_HOST, user: FTP_USER, password: FTP_PASSWORD %}
  {% ftp_download from: "/exports/products.csv" as result %}

  {% if result.ok %}
    {% assign file_content = result.file.name | content %}
    {% log file_content %}
  {% else %}
    {% log result.error %}
  {% endif %}
{% endftp_session %}
```

**Download with public URL:**

```liquid
{% ftp_session host: FTP_HOST, user: FTP_USER, password: FTP_PASSWORD %}
  {% ftp_download from: "/reports/monthly.pdf", public: true as result %}

  {% if result.ok %}
    {% log "File available at:" %}
    {% log result.file.url %}
  {% endif %}
{% endftp_session %}
```

**Download and process CSV:**

```liquid
{% ftp_session host: FTP_HOST, user: FTP_USER, password: FTP_PASSWORD, sftp: true %}
  {% ftp_download from: "/data/inventory.csv" as download %}

  {% if download.ok %}
    {% assign csv_content = download.file.name | content %}
    {% assign rows = csv_content | parse_csv %}

    {% for row in rows %}
      {% log row %}
    {% endfor %}
  {% endif %}
{% endftp_session %}
```

**Download multiple files:**

```liquid
{% ftp_session host: FTP_HOST, user: FTP_USER, password: FTP_PASSWORD %}
  {% ftp_list path: "/exports", pattern: "*.csv" as list_result %}

  {% for file in list_result.files %}
    {% ftp_download from: file.path as download %}
    {% if download.ok %}
      {% log "Downloaded: " %}
      {% log file.name %}
    {% endif %}
  {% endfor %}
{% endftp_session %}
```

#### Notes

* Must be used inside an `ftp_session` block
* Consumes 2 credits per download
* Downloaded files are stored in DataJet storage
* Use `| content` filter to read the file contents after download
* File size limits apply (10MB default, 50MB for enhanced stores)


---

# 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 dynamically by asking a question.

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

```
GET https://docs.datajet-app.com/liquid/tags/ftp_download.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
