Skip to content

Commit d314b59

Browse files
committed
resolving comments
1 parent 4df2f87 commit d314b59

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

google/cloud/storage/_media/_download.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class Download(DownloadBase):
140140
``start`` to the end of the media.
141141
headers (Optional[Mapping[str, str]]): Extra headers that should
142142
be sent with the request, e.g. headers for encrypted data.
143-
checksum Optional([str]): The type of checksum to compute to verify
143+
checksum (Optional[str]): The type of checksum to compute to verify
144144
the integrity of the object. The response headers must contain
145145
a checksum of the requested type. If the headers lack an
146146
appropriate checksum (for instance in the case of transcoded or
@@ -157,6 +157,9 @@ class Download(DownloadBase):
157157
See the retry.py source code and docstrings in this package
158158
(google.cloud.storage.retry) for information on retry types and how
159159
to configure them.
160+
single_shot_download (Optional[bool]): If true, download the object in a single request.
161+
Caution: Enabling this will increase the memory overload for your application.
162+
Please enable this as per your use case.
160163
161164
"""
162165

google/cloud/storage/blob.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,9 @@ def _do_download(
10811081
end=end,
10821082
checksum=checksum,
10831083
retry=retry,
1084+
# NOTE: single_shot_download is only supported in Download and RawDownload
1085+
# classes, i.e., when chunk_size is set to None (the default value). It is
1086+
# not supported for chunked downloads.
10841087
single_shot_download=single_shot_download,
10851088
)
10861089
with create_trace_span(

tests/resumable_media/system/requests/test_download.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ def test_download_to_stream(self, add_files, authorized_transport):
323323
assert stream.getvalue() == actual_contents
324324
check_tombstoned(download, authorized_transport)
325325

326-
def test_single_shot_download_to_stream(self, add_files, authorized_transport):
326+
@pytest.mark.parametrize("checksum", ["auto", "md5", "crc32c", None])
327+
def test_single_shot_download_to_stream(self, add_files, authorized_transport, checksum):
327328
for info in ALL_FILES:
328329
actual_contents = self._get_contents(info)
329330
blob_name = get_blob_name(info)
@@ -332,7 +333,7 @@ def test_single_shot_download_to_stream(self, add_files, authorized_transport):
332333
media_url = utils.DOWNLOAD_URL_TEMPLATE.format(blob_name=blob_name)
333334
stream = io.BytesIO()
334335
download = self._make_one(
335-
media_url, stream=stream, single_shot_download=True
336+
media_url, checksum=checksum, stream=stream, single_shot_download=True
336337
)
337338
# Consume the resource with single_shot_download enabled.
338339
response = download.consume(authorized_transport)

0 commit comments

Comments
 (0)