# Upload & downloads files (/docs/quickstart/upload-download-files)

<!-- agent-signals: reading_time_min: 4 · est_tokens: 1781 · updated: 2026-07-30 -->
Related: [Connect LLMs to E2B](/docs/quickstart/connect-llms.md), [Install custom packages](/docs/quickstart/install-custom-packages.md), [Pre-installed libraries](/docs/code-interpreting/analyze-data-with-ai/pre-installed-libraries.md)

E2B Sandbox allows you to upload and downloads file to and from the Sandbox.

An alternative way to get your data to the sandbox is to create a [custom sandbox template](/docs/template/quickstart).

## Upload file [#upload-file]

<CodeGroup>
  <CodeBlockTabs defaultValue="JavaScript & TypeScript" groupId="javascript-typescript+python">
    <CodeBlockTabsList>
      <CodeBlockTabsTrigger value="JavaScript & TypeScript">
        JavaScript & TypeScript
      </CodeBlockTabsTrigger>

      <CodeBlockTabsTrigger value="Python">
        Python
      </CodeBlockTabsTrigger>
    </CodeBlockTabsList>

    <CodeBlockTab value="JavaScript & TypeScript">
      ```ts  
      import { Sandbox } from 'e2b'

      // Read local file relative to the current working directory
      const content = fs.readFileSync('local/file')

      const sbx = await Sandbox.create()
      // Upload file to the sandbox to absolute path '/home/user/my-file'
      await sbx.files.write('/home/user/my-file', content)
      ```
    </CodeBlockTab>

    <CodeBlockTab value="Python">
      ```python  
      from e2b import Sandbox

      sbx = Sandbox.create()

      # Read local file relative to the current working directory
      with open("local/file", "rb") as file:
         # Upload file to the sandbox to absolute path '/home/user/my-file'
      	sbx.files.write("/home/user/my-file", file)
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>

## Upload multiple files [#upload-multiple-files]

Currently, if you want to upload multiple files, you need to upload each one of the separately.
We're working on a better solution.

<CodeGroup>
  <CodeBlockTabs defaultValue="JavaScript & TypeScript" groupId="javascript-typescript+python">
    <CodeBlockTabsList>
      <CodeBlockTabsTrigger value="JavaScript & TypeScript">
        JavaScript & TypeScript
      </CodeBlockTabsTrigger>

      <CodeBlockTabsTrigger value="Python">
        Python
      </CodeBlockTabsTrigger>
    </CodeBlockTabsList>

    <CodeBlockTab value="JavaScript & TypeScript">
      ```ts  
      import { Sandbox } from 'e2b'

      // Read local file relative to the current working directory
      const fileA = fs.readFileSync('local/file/a')
      const fileB = fs.readFileSync('local/file/b')

      const sbx = await Sandbox.create()
      // Upload file A to the sandbox to absolute path '/home/user/my-file-a'
      await sbx.files.write('/home/user/my-file-a', fileA)
      // Upload file B to the sandbox to absolute path '/home/user/my-file-b'
      await sbx.files.write('/home/user/my-file-b', fileB)
      ```
    </CodeBlockTab>

    <CodeBlockTab value="Python">
      ```python  
      from e2b import Sandbox

      sbx = Sandbox.create()

      # Read local file relative to the current working directory
      with open("local/file/a", "rb") as file:
         # Upload file to the sandbox to absolute path '/home/user/my-file-a'
      	sbx.files.write("/home/user/my-file-a", file)

      with open("local/file/b", "rb") as file:
         # Upload file to the sandbox to absolute path '/home/user/my-file-b'
      	sbx.files.write("/home/user/my-file-b", file)
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>

## Upload directory [#upload-directory]

We currently don't support an easy way to upload a whole directory.
You need to upload each file separately.

We're working on a better solution.

***

## Download file [#download-file]

To download a file, you need to first get the file's content and then write it to a local file.

<CodeGroup>
  <CodeBlockTabs defaultValue="JavaScript & TypeScript" groupId="javascript-typescript+python">
    <CodeBlockTabsList>
      <CodeBlockTabsTrigger value="JavaScript & TypeScript">
        JavaScript & TypeScript
      </CodeBlockTabsTrigger>

      <CodeBlockTabsTrigger value="Python">
        Python
      </CodeBlockTabsTrigger>
    </CodeBlockTabsList>

    <CodeBlockTab value="JavaScript & TypeScript">
      ```ts  
      import { Sandbox } from 'e2b'

      const sbx = await Sandbox.create()
      // Download file from the sandbox to absolute path '/home/user/my-file'
      const content = await sbx.files.read('/home/user/my-file')
      // Write file to local path relative to the current working directory
      fs.writeFileSync('local/file', content)
      ```
    </CodeBlockTab>

    <CodeBlockTab value="Python">
      ```python  
      from e2b import Sandbox

      sbx = Sandbox.create()
      # Download file from the sandbox to absolute path '/home/user/my-file'
      content = sbx.files.read('/home/user/my-file')
      # Write file to local path relative to the current working directory
      with open('local/file', 'w') as file:
          file.write(content)
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>

## Download multiple files [#download-multiple-files]

To download multiple files, you need to download each one of them separately from the sandbox.

We're working on a better solution.

<CodeGroup>
  <CodeBlockTabs defaultValue="JavaScript & TypeScript" groupId="javascript-typescript+python">
    <CodeBlockTabsList>
      <CodeBlockTabsTrigger value="JavaScript & TypeScript">
        JavaScript & TypeScript
      </CodeBlockTabsTrigger>

      <CodeBlockTabsTrigger value="Python">
        Python
      </CodeBlockTabsTrigger>
    </CodeBlockTabsList>

    <CodeBlockTab value="JavaScript & TypeScript">
      ```ts  
      import { Sandbox } from 'e2b'

      const sbx = await Sandbox.create()
      // Download file A from the sandbox by absolute path '/home/user/my-file-a'
      const contentA = await sbx.files.read('/home/user/my-file-a')
      // Write file A to local path relative to the current working directory
      fs.writeFileSync('local/file/a', contentA)

      // Download file B from the sandbox by absolute path '/home/user/my-file-b'
      const contentB = await sbx.files.read('/home/user/my-file-b')
      // Write file B to local path relative to the current working directory
      fs.writeFileSync('local/file/b', contentB)
      ```
    </CodeBlockTab>

    <CodeBlockTab value="Python">
      ```python  
      from e2b import Sandbox

      sbx = Sandbox.create()
      # Download file A from the sandbox by absolute path '/home/user/my-file-a'
      contentA = sbx.files.read('/home/user/my-file-a')
      # Write file A to local path relative to the current working directory
      with open('local/file/a', 'w') as file:
          file.write(contentA)

      # Download file B from the sandbox by absolute path '/home/user/my-file-b'
      contentB = sbx.files.read('/home/user/my-file-b')
      # Write file B to local path relative to the current working directory
      with open('local/file/b', 'w') as file:
          file.write(contentB)
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>

## Download directory [#download-directory]

We currently don't support an easy way to download a whole directory.
You need to download each file separately.

We're working on a better solution.
