Skip to content

Latest commit

 

History

History
65 lines (49 loc) · 1.46 KB

File metadata and controls

65 lines (49 loc) · 1.46 KB

Read & write files

Reading files

You can read files from the sandbox filesystem using the files.read() method.

```js import { Sandbox } from '@e2b/code-interpreter' const sandbox = await Sandbox.create() const fileContent = await sandbox.files.read('/path/to/file') ``` ```python from e2b_code_interpreter import Sandbox

sandbox = Sandbox.create() file_content = sandbox.files.read('/path/to/file')

</CodeGroup>

## Writing single files

You can write single files to the sandbox filesystem using the `files.write()` method.

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

await sandbox.files.write('/path/to/file', 'file content')
from e2b_code_interpreter import Sandbox

sandbox = Sandbox.create()

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

Writing multiple files

You can also write multiple files to the sandbox filesystem using the files.write() method.

```js 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' } ])

```python
from e2b_code_interpreter import Sandbox

sandbox = Sandbox.create()

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