Write the output to the given file. Accepts a filename or any path-like object, e.g. pathlib.Path Note: if you want to stream the data to the file instead of writing all at once then you should use `.with_streaming_response` when making the API request, e.g. `.with_
(
self,
file: str | os.PathLike[str],
)
| 480 | """ |
| 481 | |
| 482 | def write_to_file( |
| 483 | self, |
| 484 | file: str | os.PathLike[str], |
| 485 | ) -> None: |
| 486 | """Write the output to the given file. |
| 487 | |
| 488 | Accepts a filename or any path-like object, e.g. pathlib.Path |
| 489 | |
| 490 | Note: if you want to stream the data to the file instead of writing |
| 491 | all at once then you should use `.with_streaming_response` when making |
| 492 | the API request, e.g. `.with_streaming_response.get_binary_response()` |
| 493 | """ |
| 494 | with open(file, mode="wb") as f: |
| 495 | for data in self.iter_bytes(): |
| 496 | f.write(data) |
| 497 | |
| 498 | |
| 499 | class AsyncBinaryAPIResponse(AsyncAPIResponse[bytes]): |
nothing calls this directly
no test coverage detected