@@ -192,8 +192,13 @@ def __init__(
192192 if mode not in {"rb" , "wb" , "r" , "w" }:
193193 raise NotImplementedError ("File mode must be {'rb', 'wb', 'r', 'w'}, not %s" % mode )
194194 self ._mode : str = "rb" if mode is None else mode
195- if s3_block_size < 2 :
196- raise exceptions .InvalidArgumentValue ("s3_block_size MUST > 1" )
195+ self ._one_shot_download : bool = False
196+ if s3_block_size == 1 :
197+ raise exceptions .InvalidArgumentValue ("s3_block_size MUST > 1 to define a valid size or "
198+ "< 1 to avoid blocks and always execute one shot downloads." )
199+ elif s3_block_size < 1 :
200+ _logger .debug (f"s3_block_size of %d, enabling one_shot_download." , s3_block_size )
201+ self ._one_shot_download = True
197202 self ._s3_block_size : int = s3_block_size
198203 self ._s3_half_block_size : int = s3_block_size // 2
199204 self ._s3_additional_kwargs : Dict [str , str ] = {} if s3_additional_kwargs is None else s3_additional_kwargs
@@ -304,6 +309,12 @@ def _fetch(self, start: int, end: int) -> None:
304309 self ._end = end
305310 return None
306311
312+ if self ._one_shot_download :
313+ self ._start = 0
314+ self ._end = self ._size
315+ self ._cache = self ._fetch_range_proxy (self ._start , self ._end )
316+ return None
317+
307318 # Calculating block START and END positions
308319 _logger .debug ("Downloading: %s (start) / %s (end)" , start , end )
309320 mid : int = int (math .ceil ((start + (end - 1 )) / 2 ))
@@ -525,7 +536,7 @@ def open_s3_object(
525536 mode : str ,
526537 use_threads : bool = False ,
527538 s3_additional_kwargs : Optional [Dict [str , str ]] = None ,
528- s3_block_size : int = 4_194_304 , # 4 MB (4 * 2**20)
539+ s3_block_size : int = - 1 , # One shot download
529540 boto3_session : Optional [boto3 .Session ] = None ,
530541 newline : Optional [str ] = "\n " ,
531542 encoding : Optional [str ] = "utf-8" ,
0 commit comments