New File Retrieval Methods
The Vercel Sandbox SDK now includes two new methods that simplify retrieving files generated within sandbox environments:
downloadFile()- Seamlessly streams and downloads files from the sandbox to your local machinereadFileToBuffer()- Reads file contents directly into a buffer without manual stream operations
What's Changed
Previously, retrieving files from Vercel Sandbox environments required developers to manually handle stream operations and implement custom piping logic. Code running in sandboxes often generates output files—such as CSV reports, processed images, or PDF invoices—that need to be transferred across the network boundary from isolated VMs.
The new methods abstract away these low-level stream operations, providing a clean API for common file retrieval patterns.
Usage Examples
Download a file to your local machine:
const dstPath = await sandbox.downloadFile(
{ path: 'generated-file.csv', cwd: '/vercel/sandbox' },
{ path: 'generated-file.csv', cwd: '/tmp' }
);
Read file contents into memory:
const buffer = await sandbox.readFileToBuffer({ path: 'chart.png' });
Next Steps
Developers using Vercel Sandbox can immediately start leveraging these methods. Refer to the Sandbox SDK documentation and SDK reference guide for detailed usage patterns and additional capabilities.