Overview
File downloading is essential for:- Retrieving generated outputs and results
- Saving plots and visualizations
- Downloading processed data files
- Archiving sandbox contents
Download supports both text and binary files. Large files may take longer to download - set appropriate timeouts for large transfers.
Basic Download
Download a file from sandbox to local:- Python
- JavaScript
Download with Timeout
Set timeout for large file downloads:- Python
- JavaScript
Download Binary Files
Download binary files (images, PDFs, etc.):- Python
- JavaScript
Download Multiple Files
Download multiple files:- Python
- JavaScript
Download All Files in Directory
Download all files from a directory:- Python
- JavaScript
Error Handling
Handle download errors:- Python
- JavaScript
Complete Example
Hereβs a complete download workflow:- Python
- JavaScript
Best Practices
1
1. Check File Existence
Use
files.exists() before downloading to avoid errors, or handle FileNotFoundError appropriately.2
2. Set Timeouts for Large Files
For large files, set extended timeouts (60+ seconds) to avoid connection timeouts.
3
3. Create Local Directories
Create local directories before downloading to ensure files are saved correctly.
4
4. Handle Errors Gracefully
Wrap downloads in try/catch blocks to handle network errors, file not found, etc.
5
5. Verify Downloads
After downloading, verify files exist locally and check their sizes to ensure successful transfer.
Related
- Reading Files - Read file contents
- Uploading Files - Upload files to sandboxes
- Listing Files - List directory contents
- SDK: sandbox.files.download() - Python SDK method
- CLI File Operations - File operations from CLI
Next Steps
- Learn about Uploading Files to transfer files to sandboxes
- Explore Reading Files to access file contents
- Review Watching Files for real-time file monitoring

