diff --git a/examples/image/download.py b/examples/image/download.py index d5513dff7..791a65235 100644 --- a/examples/image/download.py +++ b/examples/image/download.py @@ -35,9 +35,9 @@ def download_image_stream(conn): with open("myimage.qcow2", "wb") as local_image: response = conn.image.download_image(image, stream=True) - # Read only 1024 bytes of memory at a time until + # Read only 1 MiB of memory at a time until # all of the image data has been consumed. - for chunk in response.iter_content(chunk_size=1024): + for chunk in response.iter_content(chunk_size=1024 * 1024): # With each chunk, add it to the hash to be computed. md5.update(chunk) diff --git a/openstack/cloud/_image.py b/openstack/cloud/_image.py index 1bd240fcb..8ddb5b750 100644 --- a/openstack/cloud/_image.py +++ b/openstack/cloud/_image.py @@ -121,7 +121,7 @@ class ImageCloudMixin: name_or_id, output_path=None, output_file=None, - chunk_size=1024, + chunk_size=1024 * 1024, ): """Download an image by name or ID @@ -132,7 +132,7 @@ class ImageCloudMixin: image data to. Only write() will be called on this object. Either this or output_path must be specified :param int chunk_size: size in bytes to read from the wire and buffer - at one time. Defaults to 1024 + at one time. Defaults to 1024 * 1024 = 1 MiB :returns: When output_path and output_file are not given - the bytes comprising the given Image when stream is False, otherwise a :class:`requests.Response` instance. When output_path or diff --git a/openstack/image/_download.py b/openstack/image/_download.py index cf0e687f0..efcecf73c 100644 --- a/openstack/image/_download.py +++ b/openstack/image/_download.py @@ -25,7 +25,9 @@ def _verify_checksum(md5, checksum): class DownloadMixin: - def download(self, session, stream=False, output=None, chunk_size=1024): + def download( + self, session, stream=False, output=None, chunk_size=1024 * 1024 + ): """Download the data contained in an image""" # TODO(briancurtin): This method should probably offload the get # operation into another thread or something of that nature. diff --git a/openstack/image/v1/_proxy.py b/openstack/image/v1/_proxy.py index 522d99a37..3f894b68e 100644 --- a/openstack/image/v1/_proxy.py +++ b/openstack/image/v1/_proxy.py @@ -386,7 +386,7 @@ class Proxy(proxy.Proxy): image, stream=False, output=None, - chunk_size=1024, + chunk_size=1024 * 1024, ): """Download an image @@ -411,7 +411,7 @@ class Proxy(proxy.Proxy): When ``False``, return the entire contents of the response. :param output: Either a file object or a path to store data into. :param int chunk_size: size in bytes to read from the wire and buffer - at one time. Defaults to 1024 + at one time. Defaults to 1024 * 1024 = 1 MiB :returns: When output is not given - the bytes comprising the given Image when stream is False, otherwise a :class:`requests.Response` diff --git a/openstack/image/v2/_proxy.py b/openstack/image/v2/_proxy.py index 6c6b50249..bf7e0b81f 100644 --- a/openstack/image/v2/_proxy.py +++ b/openstack/image/v2/_proxy.py @@ -776,7 +776,7 @@ class Proxy(proxy.Proxy): *, stream=False, output=None, - chunk_size=1024, + chunk_size=1024 * 1024, ): """Download an image @@ -800,7 +800,7 @@ class Proxy(proxy.Proxy): When ``False``, return the entire contents of the response. :param output: Either a file object or a path to store data into. :param int chunk_size: size in bytes to read from the wire and buffer - at one time. Defaults to 1024 + at one time. Defaults to 1024 * 1024 = 1 MiB :returns: When output is not given - the bytes comprising the given Image when stream is False, otherwise a :class:`requests.Response`