Overview
File uploading is ideal for:- Transferring local data files to sandboxes
- Uploading scripts and code files
- Moving configuration files
- Transferring datasets or models
Upload supports both text and binary files. Large files may take longer to upload - set appropriate timeouts for large transfers.
Basic Upload
Upload a file from local to sandbox:- Python
- JavaScript
Upload with Timeout
Set timeout for large file uploads:- Python
- JavaScript
Upload Multiple Files
Upload multiple files in a loop:- Python
- JavaScript
Upload Binary Files
Upload binary files (images, PDFs, etc.):- Python
- JavaScript
Upload to Specific Directory
Upload files to specific directories:- Python
- JavaScript
Error Handling
Handle upload errors:- Python
- JavaScript
Complete Example
Hereβs a complete upload workflow:- Python
- JavaScript
Best Practices
1
1. Check Local File Existence
Always verify local files exist before attempting upload to avoid errors.
2
2. Set Appropriate Timeouts
For large files, set extended timeouts (60+ seconds) to avoid connection timeouts.
3
3. Create Directories First
Use
files.mkdir() to create target directories before uploading files.4
4. Handle Errors Gracefully
Wrap uploads in try/catch blocks to handle network errors, file not found, etc.
5
5. Verify Uploads
After uploading, verify files exist and check their sizes to ensure successful transfer.
Related
- Writing Files - Write files directly in sandboxes
- Downloading Files - Download files from sandboxes
- Listing Files - List directory contents
- SDK: sandbox.files.upload() - Python SDK method
- CLI File Operations - File operations from CLI
Next Steps
- Learn about Downloading Files to retrieve files from sandboxes
- Explore Writing Files for programmatic file creation
- Review Listing Files to browse uploaded files

