Skip to main content
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

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"));
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"))
hx file upload <sandbox-id> ./local.txt /tmp/local.txt
hx file download <sandbox-id> /tmp/local.txt ./downloaded.txt

Presigned Upload And Download URLs

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);
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)
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

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.