# Download data from sandbox (/docs/filesystem/download)

<!-- agent-signals: reading_time_min: 2 · est_tokens: 854 · updated: 2026-07-30 -->
Related: [Get information about a file or directory](/docs/filesystem/info.md), [Attach custom metadata to files](/docs/filesystem/metadata.md), [Read & write files](/docs/filesystem/read-write.md), [Upload data to sandbox](/docs/filesystem/upload.md), [Watch sandbox directory for changes](/docs/filesystem/watch.md), [SSH access](/docs/sandbox/ssh-access.md)

You can download data from the sandbox using the `files.read()` method.

<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">
      ```js  
      import fs from 'fs'
      import { Sandbox } from 'e2b'

      const sandbox = await Sandbox.create()

      // Read file from sandbox
      const content = await sandbox.files.read('/path/in/sandbox')
      // Write file to local filesystem
      fs.writeFileSync('/local/path', content)
      ```
    </CodeBlockTab>

    <CodeBlockTab value="Python">
      ```python  
      from e2b import Sandbox

      sandbox = Sandbox.create()

      # Read file from sandbox
      content = sandbox.files.read('/path/in/sandbox')
      # Write file to local filesystem
      with open('/local/path', 'w') as file:
        file.write(content)
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>

## Download with pre-signed URL [#download-with-pre-signed-url]

Sometimes, you may want to let users from unauthorized environments, like a browser, download files from the sandbox.
For this use case, you can use pre-signed URLs to let users download files securely.

All you need to do is create a sandbox with the `secure: true` option. A download URL will then be generated with a signature that allows only authorized users to access files.
You can optionally set an expiration time for the URL so that it will be valid only for a limited time.

<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">
      ```js  
      import fs from 'fs'
      import { Sandbox } from 'e2b'

      // Start a secured sandbox (all operations must be authorized by default)
      const sandbox = await Sandbox.create(template, { secure: true })

      // Create a pre-signed URL for file download with a 10 second expiration
      const publicUrl = await sandbox.downloadUrl(
        'demo.txt', {
          useSignatureExpiration: 10_000, // optional
        },
      )

      // Download a file with a pre-signed URL (this can be used in any environment, such as a browser)
      const res = await fetch(publicUrl)
      const content = await res.text()
      ```
    </CodeBlockTab>

    <CodeBlockTab value="Python">
      ```python  
      from e2b import Sandbox

      # Start a secured sandbox (all operations must be authorized by default)
      sandbox = Sandbox.create(timeout=12_000, secure=True)

      # Create a pre-signed URL for file download with a 10 second expiration
      # The user only has to visit the URL to download the file, this also works in a browser.
      signed_url = sbx.download_url(path="demo.txt", user="user", use_signature_expiration=10_000)
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>
