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

# Upload, Download, And Presigned URLs

> Transfer file contents into and out of a sandbox with direct and presigned operations

Use direct transfers when your application already has the bytes in memory.

Use presigned URLs when you want a simple HTTP upload or download flow outside the SDK runtime client.

## Direct Upload And Download

<CodeGroup>
  ```typescript Node.js theme={null}
  const uploaded = await sandbox.files.upload("/tmp/data/upload.txt", "uploaded body");
  const downloaded = await sandbox.files.download("/tmp/data/upload.txt");

  console.log(uploaded.bytesWritten);
  console.log(downloaded.toString("utf8"));
  ```

  ```python Python theme={null}
  uploaded = sandbox.files.upload("/tmp/data/upload.txt", "uploaded body")
  downloaded = sandbox.files.download("/tmp/data/upload.txt")

  print(uploaded.bytes_written)
  print(downloaded.decode("utf-8"))
  ```

  ```bash CLI theme={null}
  hx file upload <sandbox-id> ./local.txt /tmp/local.txt
  hx file download <sandbox-id> /tmp/local.txt ./downloaded.txt
  ```
</CodeGroup>

## Presigned Upload And Download URLs

<CodeGroup>
  ```typescript Node.js theme={null}
  const upload = await sandbox.files.uploadUrl("/tmp/presigned.txt", {
    oneTime: true,
    expiresInSeconds: 60,
  });

  const download = await sandbox.files.downloadUrl("/tmp/presigned.txt", {
    oneTime: true,
    expiresInSeconds: 60,
  });

  console.log(upload.method, upload.url);
  console.log(download.method, download.url);
  ```

  ```python Python theme={null}
  upload = sandbox.files.upload_url(
      "/tmp/presigned.txt",
      one_time=True,
      expires_in_seconds=60,
  )

  download = sandbox.files.download_url(
      "/tmp/presigned.txt",
      one_time=True,
      expires_in_seconds=60,
  )

  print(upload.method, upload.url)
  print(download.method, download.url)
  ```

  ```bash CLI theme={null}
  hx file presign-upload <sandbox-id> /tmp/presigned.txt --expires-in-seconds 60 --one-time
  hx file presign-download <sandbox-id> /tmp/presigned.txt --expires-in-seconds 60 --one-time
  ```
</CodeGroup>

## Choosing Between Direct And Presigned Transfers

Use direct upload and download when:

* The SDK client already owns the bytes.
* You want the simplest in-process transfer path.
* You do not need to hand off the transfer to another service.

Use presigned URLs when:

* You want plain HTTP transfer behavior.
* Another service or worker should perform the upload or download.
* You want one-time or explicitly expiring transfer links.

## One-Time URLs

One-time presigned URLs are supported for both upload and download.

Only one concurrent request should succeed for a given one-time URL. Use this mode when you want handoff semantics rather than reusable access.
