diff --git a/packages/markitdown/src/markitdown/_markitdown.py b/packages/markitdown/src/markitdown/_markitdown.py index 702b10c68..1be16ab8c 100644 --- a/packages/markitdown/src/markitdown/_markitdown.py +++ b/packages/markitdown/src/markitdown/_markitdown.py @@ -362,11 +362,7 @@ def convert_stream( # Check if we have a seekable stream. If not, load the entire stream into memory. if not stream.seekable(): buffer = io.BytesIO() - while True: - chunk = stream.read(4096) - if not chunk: - break - buffer.write(chunk) + shutil.copyfileobj(stream, buffer) buffer.seek(0) stream = buffer