> ## Documentation Index
> Fetch the complete documentation index at: https://e2b.manicule.dev/llms.txt
> Use this file to discover all available pages before exploring further.
> For every page in one file, fetch https://e2b.manicule.dev/llms-full.txt (large).
> To search and read these docs as tools, connect the MCP server at https://e2b.manicule.dev/api/mcp.
> Every agent surface: https://e2b.manicule.dev/.well-known/llms-manifest.json

# Upload data to volume (/docs/volumes/upload)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 430 · updated: 2026-07-30 -->
Related: [Download data from volume](/docs/volumes/download.md), [Get information about a file or directory](/docs/volumes/info.md), [Managing volumes](/docs/volumes/manage.md), [Migrating data between volumes](/docs/volumes/migrate.md), [Mounting volumes](/docs/volumes/mount.md), [Read & write files](/docs/volumes/read-write.md)

> Upload single files or entire directories from your local filesystem to a volume.

You can upload data to a volume using the `writeFile()` / `write_file()` method.

## Upload single file

<CodeGroup>
```js title="JavaScript & TypeScript"
import fs from 'fs'
import { Volume } from 'e2b'

const volume = await Volume.create('my-volume')

// Read file from local filesystem
const content = fs.readFileSync('/local/path')
// Upload file to volume
await volume.writeFile('/path/in/volume', content)
```

```python title="Python"
from e2b import Volume

volume = Volume.create('my-volume')

# Read file from local filesystem
with open('/local/path', 'rb') as file:
    # Upload file to volume
    volume.write_file('/path/in/volume', file)
```
</CodeGroup>

## Upload directory / multiple files

<CodeGroup>
```js title="JavaScript & TypeScript"
import fs from 'fs'
import path from 'path'
import { Volume } from 'e2b'

const volume = await Volume.create('my-volume')

const directoryPath = '/local/dir'
const files = fs.readdirSync(directoryPath)

for (const file of files) {
  const fullPath = path.join(directoryPath, file)

  // Skip directories
  if (!fs.statSync(fullPath).isFile()) continue

  const content = fs.readFileSync(fullPath)
  await volume.writeFile(`/upload/${file}`, content)
}
```

```python title="Python"
import os
from e2b import Volume

volume = Volume.create('my-volume')

directory_path = '/local/dir'

for filename in os.listdir(directory_path):
    file_path = os.path.join(directory_path, filename)

    # Skip directories
    if not os.path.isfile(file_path):
        continue

    with open(file_path, 'rb') as file:
        volume.write_file(f'/upload/{filename}', file)
```
</CodeGroup>
