@@ -987,6 +987,7 @@ def _do_download(
987
987
timeout = _DEFAULT_TIMEOUT ,
988
988
checksum = "auto" ,
989
989
retry = DEFAULT_RETRY ,
990
+ single_shot_download = False ,
990
991
):
991
992
"""Perform a download without any error handling.
992
993
@@ -1047,13 +1048,20 @@ def _do_download(
1047
1048
See the retry.py source code and docstrings in this package
1048
1049
(google.cloud.storage.retry) for information on retry types and how
1049
1050
to configure them.
1051
+
1052
+ :type single_shot_download: bool
1053
+ :param single_shot_download:
1054
+ (Optional) If true, download the object in a single request.
1055
+ Caution: Enabling this will increase the memory overload for your application.
1056
+ Please enable this as per your use case.
1050
1057
"""
1051
1058
1052
1059
extra_attributes = {
1053
1060
"url.full" : download_url ,
1054
1061
"download.chunk_size" : f"{ self .chunk_size } " ,
1055
1062
"download.raw_download" : raw_download ,
1056
1063
"upload.checksum" : f"{ checksum } " ,
1064
+ "download.single_shot_download" : single_shot_download ,
1057
1065
}
1058
1066
args = {"timeout" : timeout }
1059
1067
@@ -1073,6 +1081,10 @@ def _do_download(
1073
1081
end = end ,
1074
1082
checksum = checksum ,
1075
1083
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.
1087
+ single_shot_download = single_shot_download ,
1076
1088
)
1077
1089
with create_trace_span (
1078
1090
name = f"Storage.{ download_class } /consume" ,
@@ -1127,6 +1139,7 @@ def download_to_file(
1127
1139
timeout = _DEFAULT_TIMEOUT ,
1128
1140
checksum = "auto" ,
1129
1141
retry = DEFAULT_RETRY ,
1142
+ single_shot_download = False ,
1130
1143
):
1131
1144
"""Download the contents of this blob into a file-like object.
1132
1145
@@ -1222,6 +1235,12 @@ def download_to_file(
1222
1235
(google.cloud.storage.retry) for information on retry types and how
1223
1236
to configure them.
1224
1237
1238
+ :type single_shot_download: bool
1239
+ :param single_shot_download:
1240
+ (Optional) If true, download the object in a single request.
1241
+ Caution: Enabling this will increase the memory overload for your application.
1242
+ Please enable this as per your use case.
1243
+
1225
1244
:raises: :class:`google.cloud.exceptions.NotFound`
1226
1245
"""
1227
1246
with create_trace_span (name = "Storage.Blob.downloadToFile" ):
@@ -1240,6 +1259,7 @@ def download_to_file(
1240
1259
timeout = timeout ,
1241
1260
checksum = checksum ,
1242
1261
retry = retry ,
1262
+ single_shot_download = single_shot_download ,
1243
1263
)
1244
1264
1245
1265
def _handle_filename_and_download (self , filename , * args , ** kwargs ):
@@ -1285,6 +1305,7 @@ def download_to_filename(
1285
1305
timeout = _DEFAULT_TIMEOUT ,
1286
1306
checksum = "auto" ,
1287
1307
retry = DEFAULT_RETRY ,
1308
+ single_shot_download = False ,
1288
1309
):
1289
1310
"""Download the contents of this blob into a named file.
1290
1311
@@ -1370,6 +1391,12 @@ def download_to_filename(
1370
1391
(google.cloud.storage.retry) for information on retry types and how
1371
1392
to configure them.
1372
1393
1394
+ :type single_shot_download: bool
1395
+ :param single_shot_download:
1396
+ (Optional) If true, download the object in a single request.
1397
+ Caution: Enabling this will increase the memory overload for your application.
1398
+ Please enable this as per your use case.
1399
+
1373
1400
:raises: :class:`google.cloud.exceptions.NotFound`
1374
1401
"""
1375
1402
with create_trace_span (name = "Storage.Blob.downloadToFilename" ):
@@ -1388,6 +1415,7 @@ def download_to_filename(
1388
1415
timeout = timeout ,
1389
1416
checksum = checksum ,
1390
1417
retry = retry ,
1418
+ single_shot_download = single_shot_download ,
1391
1419
)
1392
1420
1393
1421
def download_as_bytes (
@@ -1405,6 +1433,7 @@ def download_as_bytes(
1405
1433
timeout = _DEFAULT_TIMEOUT ,
1406
1434
checksum = "auto" ,
1407
1435
retry = DEFAULT_RETRY ,
1436
+ single_shot_download = False ,
1408
1437
):
1409
1438
"""Download the contents of this blob as a bytes object.
1410
1439
@@ -1484,6 +1513,12 @@ def download_as_bytes(
1484
1513
(google.cloud.storage.retry) for information on retry types and how
1485
1514
to configure them.
1486
1515
1516
+ :type single_shot_download: bool
1517
+ :param single_shot_download:
1518
+ (Optional) If true, download the object in a single request.
1519
+ Caution: Enabling this will increase the memory overload for your application.
1520
+ Please enable this as per your use case.
1521
+
1487
1522
:rtype: bytes
1488
1523
:returns: The data stored in this blob.
1489
1524
@@ -1507,6 +1542,7 @@ def download_as_bytes(
1507
1542
timeout = timeout ,
1508
1543
checksum = checksum ,
1509
1544
retry = retry ,
1545
+ single_shot_download = single_shot_download ,
1510
1546
)
1511
1547
return string_buffer .getvalue ()
1512
1548
@@ -1524,6 +1560,7 @@ def download_as_string(
1524
1560
if_metageneration_not_match = None ,
1525
1561
timeout = _DEFAULT_TIMEOUT ,
1526
1562
retry = DEFAULT_RETRY ,
1563
+ single_shot_download = False ,
1527
1564
):
1528
1565
"""(Deprecated) Download the contents of this blob as a bytes object.
1529
1566
@@ -1594,6 +1631,12 @@ def download_as_string(
1594
1631
(google.cloud.storage.retry) for information on retry types and how
1595
1632
to configure them.
1596
1633
1634
+ :type single_shot_download: bool
1635
+ :param single_shot_download:
1636
+ (Optional) If true, download the object in a single request.
1637
+ Caution: Enabling this will increase the memory overload for your application.
1638
+ Please enable this as per your use case.
1639
+
1597
1640
:rtype: bytes
1598
1641
:returns: The data stored in this blob.
1599
1642
@@ -1616,6 +1659,7 @@ def download_as_string(
1616
1659
if_metageneration_not_match = if_metageneration_not_match ,
1617
1660
timeout = timeout ,
1618
1661
retry = retry ,
1662
+ single_shot_download = single_shot_download ,
1619
1663
)
1620
1664
1621
1665
def download_as_text (
@@ -1633,6 +1677,7 @@ def download_as_text(
1633
1677
if_metageneration_not_match = None ,
1634
1678
timeout = _DEFAULT_TIMEOUT ,
1635
1679
retry = DEFAULT_RETRY ,
1680
+ single_shot_download = False ,
1636
1681
):
1637
1682
"""Download the contents of this blob as text (*not* bytes).
1638
1683
@@ -1705,6 +1750,12 @@ def download_as_text(
1705
1750
(google.cloud.storage.retry) for information on retry types and how
1706
1751
to configure them.
1707
1752
1753
+ :type single_shot_download: bool
1754
+ :param single_shot_download:
1755
+ (Optional) If true, download the object in a single request.
1756
+ Caution: Enabling this will increase the memory overload for your application.
1757
+ Please enable this as per your use case.
1758
+
1708
1759
:rtype: text
1709
1760
:returns: The data stored in this blob, decoded to text.
1710
1761
"""
@@ -1722,6 +1773,7 @@ def download_as_text(
1722
1773
if_metageneration_not_match = if_metageneration_not_match ,
1723
1774
timeout = timeout ,
1724
1775
retry = retry ,
1776
+ single_shot_download = single_shot_download ,
1725
1777
)
1726
1778
1727
1779
if encoding is not None :
@@ -4019,6 +4071,7 @@ def open(
4019
4071
For downloads only, the following additional arguments are supported:
4020
4072
4021
4073
- ``raw_download``
4074
+ - ``single_shot_download``
4022
4075
4023
4076
For uploads only, the following additional arguments are supported:
4024
4077
@@ -4209,6 +4262,7 @@ def _prep_and_do_download(
4209
4262
timeout = _DEFAULT_TIMEOUT ,
4210
4263
checksum = "auto" ,
4211
4264
retry = DEFAULT_RETRY ,
4265
+ single_shot_download = False ,
4212
4266
command = None ,
4213
4267
):
4214
4268
"""Download the contents of a blob object into a file-like object.
@@ -4294,6 +4348,12 @@ def _prep_and_do_download(
4294
4348
(google.cloud.storage.retry) for information on retry types and how
4295
4349
to configure them.
4296
4350
4351
+ :type single_shot_download: bool
4352
+ :param single_shot_download:
4353
+ (Optional) If true, download the object in a single request.
4354
+ Caution: Enabling this will increase the memory overload for your application.
4355
+ Please enable this as per your use case.
4356
+
4297
4357
:type command: str
4298
4358
:param command:
4299
4359
(Optional) Information about which interface for download was used,
@@ -4349,6 +4409,7 @@ def _prep_and_do_download(
4349
4409
timeout = timeout ,
4350
4410
checksum = checksum ,
4351
4411
retry = retry ,
4412
+ single_shot_download = single_shot_download ,
4352
4413
)
4353
4414
except InvalidResponse as exc :
4354
4415
_raise_from_invalid_response (exc )
0 commit comments