Reading files
You can read files from the sandbox filesystem using thefiles.read() method.
Writing single files
You can write single files to the sandbox filesystem using thefiles.write() method.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
files.read() method.
import { Sandbox } from 'e2b'
const sandbox = await Sandbox.create()
const fileContent = await sandbox.files.read('/path/to/file')
from e2b import Sandbox
sandbox = Sandbox.create()
file_content = sandbox.files.read('/path/to/file')
files.write() method.
import { Sandbox } from 'e2b'
const sandbox = await Sandbox.create()
await sandbox.files.write('/path/to/file', 'file content')
from e2b import Sandbox
sandbox = Sandbox.create()
sandbox.files.write('/path/to/file', 'file content')
import { Sandbox } from 'e2b'
const sandbox = await Sandbox.create()
await sandbox.files.write([
{ path: '/path/to/a', data: 'file content' },
{ path: '/another/path/to/b', data: 'file content' }
])
from e2b import Sandbox
sandbox = Sandbox.create()
sandbox.files.write_files([
{ "path": "/path/to/a", "data": "file content" },
{ "path": "another/path/to/b", "data": "file content" }
])
Was this page helpful?