ITADN
fal-ai/fal/Issues

files: stream large file downloads with chunked writes and progress bar

#986OpenGitGlimpse895 创建于 2026-04-17
G
GitGlimpse895commented
## Problem `get_file` in `projects/fal/src/fal/files.py` currently buffers the entire response body into RAM via `response.content` before writing to disk. For large files like model weights or datasets this causes: - OOM risk on memory-constrained machines - Zero user feedback — terminal appears frozen until all bytes arrive - High peak memory usage even for mid-sized files ## Solution Replace the buffered download with httpx's `stream()` context manager that writes chunks incrementally, paired with a rich progress bar (DownloadColumn + TransferSpeedColumn) — matching the existing put_file UX. Zero new dependencies. Both httpx streaming and rich are already used in this file. ## Changes - Added `DOWNLOAD_CHUNK_SIZE = 10 * 1024 * 1024` constant - Replaced `response.content` with `response.iter_bytes(DOWNLOAD_CHUNK_SIZE)` - Added streaming progress bar with download speed and byte count ## Branch My implementation is ready and can be viewed here: https://github.com/GitGlimpse895/fal/tree/stream-file-downloads
1 条评论