import fs from 'fs'
import { Sandbox } from '@e2b/code-interpreter'
// Start a secured sandbox (all operations must be authorized by default)
const sandbox = await Sandbox.create(template, { secure: true })
// Create a pre-signed URL for file download with a 10 second expiration
const publicUrl = await sandbox.downloadUrl(
'demo.txt', {
useSignatureExpiration: 10_000, // optional
},
)
// Download a file with a pre-signed URL (this can be used in any environment, such as a browser)
const res = await fetch(publicUrl)
const content = await res.text()