download_file
Download files from HTTP/HTTPS URLs to local directories or file paths. Includes options for custom filenames, headers, and overwrite control.
Instructions
Download a file from a URL to a local directory or file path.
Features:
Supports HTTP and HTTPS protocols
Streams large files efficiently (no memory pressure)
Auto-detects filename from URL or Content-Disposition header
Creates parent directories automatically
Configurable timeout (300s) and size limit (500MB)
Safe filename sanitization (removes dangerous characters)
Examples:
Download to directory: { "url": "https://example.com/file.pdf", "dest_path": "/home/user/downloads" }
Download with custom name: { "url": "https://example.com/data.csv", "dest_path": "/tmp", "filename": "my_data.csv" }
With auth headers: { "url": "https://api.example.com/export", "dest_path": "./output.json", "headers": { "Authorization": "Bearer token123" } }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The URL of the file to download (http/https only) | |
| headers | No | Optional HTTP headers as key-value pairs (e.g., {'Authorization': 'Bearer token'}) | |
| filename | No | Optional custom filename. Only used when dest_path is a directory. Unsafe characters will be sanitized automatically. | |
| dest_path | Yes | Destination directory path or full file path. If a directory is specified, the filename will be auto-detected from the URL. | |
| overwrite | No | Whether to overwrite the file if it already exists. Default: false |