Skip to content
Myr

streaming doc clarification

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Nate Prewitt · committed by Nate Prewitt · parent b9f1c44 · Browse files · 1 file+3 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−2 removed

  • other:+3 added−2 removed

1 file+3 added−2 removed

modified:docs/user/quickstart.rst+3 added-2 removed
176 unmodified lines
177In general, however, you should use a pattern like this to save what is being178streamed to a file::179180 with open(filename, 'wb') as fd:181 for chunk in r.iter_content(chunk_size):181 for chunk in r.iter_content(chunk_size=128):182 fd.write(chunk)183184Using ``Response.iter_content`` will handle a lot of what you would otherwise185have to handle when using ``Response.raw`` directly. When streaming a186download, the above is the preferred and recommended way to retrieve the187content. Note that ``chunk_size`` is optional.187content. Note that ``chunk_size`` can be freely adjusted to a number that188may better fit your use cases.189190191Custom Headers192--------------
336 unmodified lines