Download files
In JavaScript/Python, request bytes from files.read and save them with your application’s filesystem API. In Go, use Files.ReadTo to stream the contents into an io.Writer:
mjs
import { writeFile } from "node:fs/promises";
import { URL } from "node:url";
import { Sandbox } from "@abox-dev/sdk";
const sandbox = await Sandbox.create();
try {
await sandbox.files.write("/tmp/report.txt", "Report is ready");
const report = await sandbox.files.read("/tmp/report.txt", {
format: "bytes",
});
await writeFile(new URL("./report.txt", import.meta.url), report);
console.log("Downloaded report.txt");
} finally {
await sandbox.kill();
}Use the streamed read format for files that should not be buffered entirely in memory.