读取文件

您可以使用 files.read() 方法从沙箱文件系统中读取文件。

import { Sandbox } from '@e2b/code-interpreter'

const sandbox = await Sandbox.create()
const fileContent = await sandbox.files.read('/path/to/file')

写入单个文件

您可以使用 files.write() 方法将单个文件写入沙箱文件系统。

import { Sandbox } from '@e2b/code-interpreter'
const sandbox = await Sandbox.create()

await sandbox.files.write('/path/to/file', 'file content')

写入多个文件

您也可以使用 files.write() 方法将多个文件写入沙箱文件系统。

import { Sandbox } from '@e2b/code-interpreter'
const sandbox = await Sandbox.create()

await sandbox.files.write([
    { path: '/path/to/a', data: 'file content' },
    { path: '/another/path/to/b', data: 'file content' }
])