---
related_nodes: ["upload_media"]
---

# Download Attachment

Downloads a file from a URL straight into a Library item and outputs the item's object descriptor, the same descriptor an upload produces.

## Inputs

- `url` - required. The file's URL, fetched with a `GET`.
- `filename` - optional. Names the item when `name` is empty. Without either, the last path segment of the URL is used, unless that segment is empty or contains `?` or `#`; then the item is named `download`.
- `content_type` - optional. Overrides the stored MIME type. Without it, the response's `Content-Type` is used without its parameters.

## Configuration

- `name` - the Library item's name, with `{{ }}` interpolation over the inputs. Empty takes the `filename` input, else the URL's last segment.
- `place` - defaults to Folder (`folder`). Choose Other (`other`) to file the item outside every folder.
- `folder` - folder slugs or ids from the Library root, separated by `/`, with interpolation. Every folder must already exist. Use the Library node's Create Folder first if you need a new folder.
- `max_size_mb` - largest file saved, in MB, from `1` to `2048` (2 GiB). Default `50`. A response whose `Content-Length` is larger is refused before anything is read; a body without a `Content-Length` is stopped as soon as it passes the limit. A value outside the range is reported when the workflow is validated, and the step fails.
- `retry` - whether the download is sent again after a failure that passes: a rate limit, a busy server, a dropped connection. Off by default; see [Retries](http_get.md#retries). The fetch is a `GET`, a read, so it is sent again freely.

## Outputs

- `media` - the saved item's object descriptor:

```json
{
  "object_id": "01J...",
  "filename": "invoice.pdf",
  "content_type": "application/pdf",
  "size_bytes": 48213,
  "metadata": {}
}
```

- `success` - `true` when the file was saved, `false` when a download error is returned on `error`.
- `error` - the failure message when the download failed.

An error before saving the file, such as a non-success HTTP status or an oversized `Content-Length`, returns `success: false` and an `error` message, and skips `media`. A blank or missing folder, or a Library save error, fails the node and follows its failure mode. On success, `error` is skipped.

### Route to error output

With the failure mode set to **Route to error output** (`base_config.failure_mode: "route_to_error"`), a failed download fails the node instead of returning `success: false`. `media` and `success` are skipped, and `error` carries the node error value (`node_id`, `node_type`, `message`, `causes`) in place of the text. The run records the node as failed with its error routed and completes with warnings.

## Behavior

- The body streams into storage as it arrives; it is never held whole in memory, so a file up to the 2 GiB cap fits.
- There is no total time limit on the download. Each connection attempt has 30 seconds, and the download fails when nothing arrives for 60 seconds. The workflow's own timeout bounds the whole run.
- A failed save leaves nothing behind: no item, no partial object, and no storage quota used.
- The URL and any redirect from it go through the workspace's outbound address policy; a URL that resolves to a non-public address is refused without connecting when that policy allows public addresses only.
- A response that is not a success status fails the download with `HTTP error: <status>`.

## Runtime Errors

| Error | Cause |
|-------|-------|
| `Missing required input: url` | Nothing reached the `url` input. This fails the step. |
| `Maximum file size must be between 1 and 2048 MB` | `max_size_mb` is out of range. This fails the step. |
| `Choose a folder, or choose Other to file the item outside every folder.` | Folder was selected but no path was given. This fails the step. |
| `Invalid attachment URL` | The URL could not be parsed. |
| `URL resolves to a non-public address` | The URL points at an internal address. |
| `HTTP error: <status>` | The server answered with a non-success status. |
| `File too large: ...` | The response's `Content-Length` is larger than `max_size_mb`. |
| Any other message | The Library could not save the file. The node fails if a folder is missing, the body grows past `max_size_mb`, the storage quota is full, the download stalls, or storage fails. |
