> ## Documentation Index
> Fetch the complete documentation index at: https://e2b.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload data to volume

> 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 JavaScript & TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
  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 Python theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
  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 JavaScript & TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
  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 Python theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
  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>
