@@ -358,8 +358,8 @@ def public_url(options = {})
358358 # {Client#complete_multipart_upload},
359359 # and {Client#upload_part} can be provided.
360360 #
361- # @option options [Integer] :thread_count (10) The number of parallel
362- # multipart uploads
361+ # @option options [Integer] :thread_count (10) The number of parallel multipart uploads.
362+ # An additional thread is used internally for task coordination.
363363 #
364364 # @option options [Boolean] :tempfile (false) Normally read data is stored
365365 # in memory when building the parts in order to complete the underlying
@@ -383,19 +383,18 @@ def public_url(options = {})
383383 # @see Client#complete_multipart_upload
384384 # @see Client#upload_part
385385 def upload_stream ( options = { } , &block )
386- uploading_options = options . dup
386+ upload_opts = options . merge ( bucket : bucket_name , key : key )
387+ executor = DefaultExecutor . new ( max_threads : upload_opts . delete ( :thread_count ) )
387388 uploader = MultipartStreamUploader . new (
388389 client : client ,
389- thread_count : uploading_options . delete ( :thread_count ) ,
390- tempfile : uploading_options . delete ( :tempfile ) ,
391- part_size : uploading_options . delete ( :part_size )
390+ executor : executor ,
391+ tempfile : upload_opts . delete ( :tempfile ) ,
392+ part_size : upload_opts . delete ( :part_size )
392393 )
393394 Aws ::Plugins ::UserAgent . metric ( 'RESOURCE_MODEL' ) do
394- uploader . upload (
395- uploading_options . merge ( bucket : bucket_name , key : key ) ,
396- &block
397- )
395+ uploader . upload ( upload_opts , &block )
398396 end
397+ executor . shutdown
399398 true
400399 end
401400 deprecated ( :upload_stream , use : 'Aws::S3::TransferManager#upload_stream' , version : 'next major version' )
@@ -458,12 +457,18 @@ def upload_stream(options = {}, &block)
458457 # @see Client#complete_multipart_upload
459458 # @see Client#upload_part
460459 def upload_file ( source , options = { } )
461- uploading_options = options . dup
462- uploader = FileUploader . new ( multipart_threshold : uploading_options . delete ( :multipart_threshold ) , client : client )
460+ upload_opts = options . merge ( bucket : bucket_name , key : key )
461+ executor = DefaultExecutor . new ( max_threads : upload_opts . delete ( :thread_count ) )
462+ uploader = FileUploader . new (
463+ client : client ,
464+ executor : executor ,
465+ multipart_threshold : upload_opts . delete ( :multipart_threshold )
466+ )
463467 response = Aws ::Plugins ::UserAgent . metric ( 'RESOURCE_MODEL' ) do
464- uploader . upload ( source , uploading_options . merge ( bucket : bucket_name , key : key ) )
468+ uploader . upload ( source , upload_opts )
465469 end
466470 yield response if block_given?
471+ executor . shutdown
467472 true
468473 end
469474 deprecated ( :upload_file , use : 'Aws::S3::TransferManager#upload_file' , version : 'next major version' )
@@ -512,10 +517,6 @@ def upload_file(source, options = {})
512517 #
513518 # @option options [Integer] :thread_count (10) Customize threads used in the multipart download.
514519 #
515- # @option options [String] :version_id The object version id used to retrieve the object.
516- #
517- # @see https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectVersioning.html ObjectVersioning
518- #
519520 # @option options [String] :checksum_mode ("ENABLED")
520521 # When `"ENABLED"` and the object has a stored checksum, it will be used to validate the download and will
521522 # raise an `Aws::Errors::ChecksumError` if checksum validation fails. You may provide a `on_checksum_validated`
@@ -539,10 +540,13 @@ def upload_file(source, options = {})
539540 # @see Client#get_object
540541 # @see Client#head_object
541542 def download_file ( destination , options = { } )
542- downloader = FileDownloader . new ( client : client )
543+ download_opts = options . merge ( bucket : bucket_name , key : key )
544+ executor = DefaultExecutor . new ( max_threads : download_opts . delete ( [ :thread_count ] ) )
545+ downloader = FileDownloader . new ( client : client , executor : executor )
543546 Aws ::Plugins ::UserAgent . metric ( 'RESOURCE_MODEL' ) do
544- downloader . download ( destination , options . merge ( bucket : bucket_name , key : key ) )
547+ downloader . download ( destination , download_opts )
545548 end
549+ executor . shutdown
546550 true
547551 end
548552 deprecated ( :download_file , use : 'Aws::S3::TransferManager#download_file' , version : 'next major version' )
0 commit comments