Class: Aws::S3::FileDownloader Private
- Inherits:
-
Object
- Object
- Aws::S3::FileDownloader
- Defined in:
- lib/aws-sdk-s3/file_downloader.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: MultipartProgress, Part, PartList
Constant Summary collapse
- MIN_CHUNK_SIZE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
5 * 1024 * 1024
- MAX_PARTS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
10_000
- THREAD_COUNT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
10
Instance Attribute Summary collapse
- #client ⇒ Client readonly private
Instance Method Summary collapse
- #download(destination, options = {}) ⇒ Object private
-
#initialize(options = {}) ⇒ FileDownloader
constructor
private
A new instance of FileDownloader.
Constructor Details
#initialize(options = {}) ⇒ FileDownloader
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of FileDownloader.
17 18 19 |
# File 'lib/aws-sdk-s3/file_downloader.rb', line 17 def initialize( = {}) @client = [:client] || Client.new end |
Instance Attribute Details
#client ⇒ Client (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 |
# File 'lib/aws-sdk-s3/file_downloader.rb', line 22 def client @client end |
Instance Method Details
#download(destination, options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/aws-sdk-s3/file_downloader.rb', line 24 def download(destination, = {}) @path = destination @mode = [:mode] || 'auto' @thread_count = [:thread_count] || THREAD_COUNT @chunk_size = [:chunk_size] @params = { bucket: [:bucket], key: [:key], } @params[:version_id] = [:version_id] if [:version_id] # checksum_mode only supports the value "ENABLED" # falsey values (false/nil) or "DISABLED" should be considered # disabled and the api parameter should be unset. if (checksum_mode = .fetch(:checksum_mode, 'ENABLED')) @params[:checksum_mode] = checksum_mode unless checksum_mode.upcase == 'DISABLED' end @on_checksum_validated = [:on_checksum_validated] @progress_callback = [:progress_callback] validate! Aws::Plugins::UserAgent.metric('S3_TRANSFER') do case @mode when 'auto' then multipart_download when 'single_request' then single_request when 'get_range' if @chunk_size resp = @client.head_object(@params) multithreaded_get_by_ranges(resp.content_length) else msg = 'In :get_range mode, :chunk_size must be provided' raise ArgumentError, msg end else msg = "Invalid mode #{@mode} provided, "\ 'mode should be :single_request, :get_range or :auto' raise ArgumentError, msg end end end |