Skip to content

Commit 4f27bcf

Browse files
committed
Skip HEAD for multipart check when multipart_threshold is None
1 parent f6e0cf3 commit 4f27bcf

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

s3transfer/download.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def _submit(
346346
:param bandwidth_limiter: The bandwidth limiter to use when
347347
downloading streams
348348
"""
349-
if transfer_future.meta.size is None:
349+
if transfer_future.meta.size is None and config.multipart_threshold is not None:
350350
# If a size was not provided figure out the size for the
351351
# user.
352352
response = client.head_object(
@@ -364,7 +364,7 @@ def _submit(
364364

365365
# If it is greater than threshold do a ranged download, otherwise
366366
# do a regular GetObject download.
367-
if transfer_future.meta.size < config.multipart_threshold:
367+
if config.multipart_threshold is None or transfer_future.meta.size < config.multipart_threshold:
368368
self._submit_download_request(
369369
client,
370370
config,

s3transfer/upload.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def provide_transfer_size(self, transfer_future):
245245
)
246246

247247
def requires_multipart_upload(self, transfer_future, config):
248-
return transfer_future.meta.size >= config.multipart_threshold
248+
return config.multipart_threshold is not None and transfer_future.meta.size >= config.multipart_threshold
249249

250250
def get_put_object_body(self, transfer_future):
251251
# Get a file-like object for the given input
@@ -393,14 +393,14 @@ def provide_transfer_size(self, transfer_future):
393393
def requires_multipart_upload(self, transfer_future, config):
394394
# If the user has set the size, we can use that.
395395
if transfer_future.meta.size is not None:
396-
return transfer_future.meta.size >= config.multipart_threshold
396+
return config.multipart_threshold is not None and transfer_future.meta.size >= config.multipart_threshold
397397

398398
# This is tricky to determine in this case because we can't know how
399399
# large the input is. So to figure it out, we read data into memory
400400
# up until the threshold and compare how much data was actually read
401401
# against the threshold.
402402
fileobj = transfer_future.meta.call_args.fileobj
403-
threshold = config.multipart_threshold
403+
threshold = config.multipart_threshold or 8 * 1024 * 1024
404404
self._initial_data = self._read(fileobj, threshold, False)
405405
if len(self._initial_data) < threshold:
406406
return False

0 commit comments

Comments
 (0)