Skip to content

feat(sdk): add streaming download_to_file for devbox files#816

Open
jrvb-rl wants to merge 1 commit into
mainfrom
fix/stream-download-files
Open

feat(sdk): add streaming download_to_file for devbox files#816
jrvb-rl wants to merge 1 commit into
mainfrom
fix/stream-download-files

Conversation

@jrvb-rl

@jrvb-rl jrvb-rl commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

devbox.file.download() reads the entire file into memory (response.read()), the mirror image of the upload-side buffering. This adds download_to_file(dest) on both the sync and async FileInterface that streams the response body straight to disk in chunks via with_streaming_response, so large downloads never have to fit in RAM.

The existing download() (returns bytes) is kept unchanged for small-file convenience — streaming into a bytes return is impossible by definition, so this is additive rather than a behavior change.

Companion to #815 (streaming uploads).

Changes

  • sdk/devbox.py / sdk/async_devbox.py: new download_to_file(dest, *, chunk_size=None, **params) using with_streaming_response.download_file(...) + stream_to_file.
  • Tests: test_download_to_file (sync + async) assert the body is streamed to disk and the correct path is forwarded.

Usage

devbox.file.download_to_file("local_output.bin", path="/home/user/output.bin")
# async:
await devbox.file.download_to_file("local_output.bin", path="/home/user/output.bin")

Test plan

  • uv run pytest tests/sdk/devbox tests/sdk/async_devbox — 95 passed
  • ruff check clean

🤖 Generated with Claude Code

devbox.file.download() reads the entire file into memory via response.read(),
which is wasteful for large downloads — the mirror image of the upload-side
buffering. Add download_to_file(dest) on both the sync and async FileInterface
that streams the response body to disk in chunks via with_streaming_response,
so large files never have to fit in memory. The buffered download() is kept for
small-file convenience.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant