Download File
Downloads a file from a given URL and saves it to the specified path on the local machine. Supports basic authentication.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
if ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.
Input
- URL - The URL of the file to be downloaded
- Download Path - The location where the downloaded file will be saved
Output
- Path - The path where the downloaded file was saved
Options
- Basic Authentication - The credentials needed for basic HTTP authentication
- Timeout - The maximum time in seconds for the download to complete (default: 120 seconds)
- Temp File Pattern - The pattern for the name of the temporary file used during the download
- Cookie Store - Optional cookie store for session-based downloads
The file downloaded will have the same name as the original file. If the file has spaces in its name, it will be replaced by %20 in the file name.
How It Works
The Download File node retrieves files from URLs and saves them locally:
-
Input Validation:
- Validates and normalizes the URL (adds http:// if protocol is missing)
- Parses the URL to ensure it's valid
- Validates the download path or creates a temporary file if path is empty
-
Authentication Setup:
- If credentials are provided, retrieves them from the vault
- Sets up basic authentication headers
- Adds cookies from cookie store if provided
-
Download Process:
- Creates an HTTP client with the specified timeout (default: 120 seconds)
- Sends a GET request to the URL with authentication and cookies
- Checks the HTTP status code (fails if 4 or greater00)
- Streams the response body directly to the file
-
File Saving:
- If download path is provided, creates the file at that location
- If no path is provided, creates a temporary file using the temp file pattern
- Returns the final path where the file was saved
Requirements
- URL: Must be a valid HTTP/HTTPS URL (protocol is optional, defaults to http://)
- Download Path: Optional; if empty, a temporary file is created
- File Permissions: Write permissions required for the download directory
- Network Access: Active internet connection to reach the URL
- Credentials: Valid vault credentials if basic authentication is required
Error Handling
| Error Code | Description | Solution |
|---|---|---|
Core.Net.Download.ErrOnCreate | Configuration parsing failed during node creation | Check node configuration in the flow |
Core.Net.Download.OnMessage | Message parsing error | Verify message format is valid JSON |
Core.Net.Download.ErrCredentials | Failed to retrieve or parse credentials | Check vault credentials configuration |
Core.Net.Download.ErrURL | URL is empty or invalid | Provide a valid URL |
Core.Net.Download.ErrTempFile | Failed to create temporary file | Check system temp directory permissions |
Core.Net.Download.ErrCreate | Failed to create file at specified path | Verify path exists and has write permissions |
Core.Net.Download.Err | Download failed (network error, timeout, HTTP error) | Check URL, network connection, and timeout settings |
Core.Net.Download.ErrOutputMarshal | Failed to serialize output | Check output variable configuration |
Usage Examples
Example 1: Simple File Download
// Download a PDF file to a specific location
msg.url = "https://example.com/document.pdf";
msg.downloadPath = "/home/user/downloads/document.pdf";
// After node execution:
// msg.savedPath contains "/home/user/downloads/document.pdf"
// File is saved at the specified location
Example 2: Download to Temporary File
// Download to a temporary location
msg.fileUrl = "https://example.com/data.csv";
msg.path = ""; // Empty path creates temp file
// After node execution:
// msg.filePath contains something like "/tmp/tmpXYZ123"
// File is saved to system temp directory
Example 3: Download with Authentication
// Download protected file with basic auth
msg.downloadUrl = "https://secure.example.com/report.xlsx";
msg.savePath = "/downloads/report.xlsx";
// Configure Basic Authentication option in node:
// - Select vault ID and item ID with username/password
// After node execution:
// File is downloaded using provided credentials
Usage Notes
- Default Timeout: 120 seconds (2 minutes) if not specified
- URL Auto-Correction: URLs without protocol are automatically prefixed with
http:// - HTTP Status Codes: Any response with status code 4 or greater00 is treated as an error
- Streaming: Files are streamed directly to disk, not loaded into memory
- Temporary Files: When no path is provided, files are created in the system temp directory
- File Overwrite: If the target file exists, it will be overwritten without warning
- Spaces in URLs: URL encoding is handled automatically by the HTTP client
- Cookie Support: Can use cookies from previous HTTP requests via cookie store
- Large Files: Suitable for large file downloads due to streaming approach
Tips
- Use temporary files for intermediate processing, then move to final location
- Set appropriate timeout values based on expected file size and connection speed
- Store credentials in vault instead of hardcoding in the flow
- Check if the file exists before downloading to avoid unnecessary downloads
- Combine with file size checks to verify successful download
- Use try-catch to handle download failures gracefully
- For unreliable connections, consider implementing retry logic
- Validate downloaded file integrity (size, checksum) after download
- Clean up temporary files after processing to avoid disk space issues
Related Nodes
- HTTP Request - Make API calls and retrieve data
- File Operations - Check file existence, move, or delete downloaded files
- Vault - Store and retrieve authentication credentials
- String Operations - Build dynamic URLs from components