aws-sdk-s3 1.182.0 → 1.198.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +106 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-s3/bucket.rb +46 -6
- data/lib/aws-sdk-s3/client.rb +1693 -591
- data/lib/aws-sdk-s3/client_api.rb +396 -162
- data/lib/aws-sdk-s3/customizations/object.rb +57 -76
- data/lib/aws-sdk-s3/customizations.rb +2 -1
- data/lib/aws-sdk-s3/endpoint_provider.rb +234 -129
- data/lib/aws-sdk-s3/endpoints.rb +84 -0
- data/lib/aws-sdk-s3/errors.rb +11 -0
- data/lib/aws-sdk-s3/file_downloader.rb +65 -82
- data/lib/aws-sdk-s3/file_uploader.rb +3 -5
- data/lib/aws-sdk-s3/legacy_signer.rb +2 -1
- data/lib/aws-sdk-s3/multipart_download_error.rb +8 -0
- data/lib/aws-sdk-s3/multipart_file_uploader.rb +34 -65
- data/lib/aws-sdk-s3/multipart_stream_uploader.rb +80 -88
- data/lib/aws-sdk-s3/multipart_upload.rb +4 -2
- data/lib/aws-sdk-s3/multipart_upload_error.rb +3 -4
- data/lib/aws-sdk-s3/object.rb +85 -26
- data/lib/aws-sdk-s3/object_acl.rb +7 -1
- data/lib/aws-sdk-s3/object_multipart_copier.rb +2 -1
- data/lib/aws-sdk-s3/object_summary.rb +54 -24
- data/lib/aws-sdk-s3/plugins/streaming_retry.rb +5 -7
- data/lib/aws-sdk-s3/plugins/url_encoded_keys.rb +2 -1
- data/lib/aws-sdk-s3/resource.rb +6 -0
- data/lib/aws-sdk-s3/transfer_manager.rb +246 -0
- data/lib/aws-sdk-s3/types.rb +1627 -295
- data/lib/aws-sdk-s3.rb +1 -1
- data/sig/bucket.rbs +12 -3
- data/sig/client.rbs +143 -31
- data/sig/errors.rbs +2 -0
- data/sig/multipart_upload.rbs +1 -1
- data/sig/object.rbs +13 -10
- data/sig/object_summary.rbs +9 -9
- data/sig/resource.rbs +8 -1
- data/sig/types.rbs +183 -29
- metadata +8 -9
@@ -398,14 +398,14 @@ module Aws
|
|
398
398
|
end
|
399
399
|
true
|
400
400
|
end
|
401
|
+
deprecated(:upload_stream, use: 'Aws::S3::TransferManager#upload_stream', version: 'next major version')
|
401
402
|
|
402
403
|
# Uploads a file from disk to the current object in S3.
|
403
404
|
#
|
404
405
|
# # small files are uploaded in a single API call
|
405
406
|
# obj.upload_file('/path/to/file')
|
406
407
|
#
|
407
|
-
# Files larger than or equal to `:multipart_threshold` are uploaded
|
408
|
-
# using the Amazon S3 multipart upload APIs.
|
408
|
+
# Files larger than or equal to `:multipart_threshold` are uploaded using the Amazon S3 multipart upload APIs.
|
409
409
|
#
|
410
410
|
# # large files are automatically split into parts
|
411
411
|
# # and the parts are uploaded in parallel
|
@@ -421,47 +421,37 @@ module Aws
|
|
421
421
|
# You can provide a callback to monitor progress of the upload:
|
422
422
|
#
|
423
423
|
# # bytes and totals are each an array with 1 entry per part
|
424
|
-
# progress =
|
425
|
-
# puts bytes.map.with_index { |b, i| "Part #{i+1}: #{b} / #{totals[i]}"}.join(' ') + "Total: #{100.0 * bytes.sum / totals.sum }%"
|
424
|
+
# progress = proc do |bytes, totals|
|
425
|
+
# puts bytes.map.with_index { |b, i| "Part #{i+1}: #{b} / #{totals[i]}"}.join(' ') + "Total: #{100.0 * bytes.sum / totals.sum }%"
|
426
426
|
# end
|
427
427
|
# obj.upload_file('/path/to/file', progress_callback: progress)
|
428
428
|
#
|
429
|
-
# @param [String, Pathname, File, Tempfile] source A file on the local
|
430
|
-
#
|
431
|
-
#
|
432
|
-
#
|
433
|
-
# you are responsible for closing it after the upload completes. When
|
434
|
-
# using an open Tempfile, rewind it before uploading or else the object
|
429
|
+
# @param [String, Pathname, File, Tempfile] source A file on the local file system that will be uploaded as
|
430
|
+
# this object. This can either be a String or Pathname to the file, an open File object, or an open
|
431
|
+
# Tempfile object. If you pass an open File or Tempfile object, then you are responsible for closing it
|
432
|
+
# after the upload completes. When using an open Tempfile, rewind it before uploading or else the object
|
435
433
|
# will be empty.
|
436
434
|
#
|
437
435
|
# @param [Hash] options
|
438
|
-
# Additional options for {Client#put_object}
|
439
|
-
#
|
440
|
-
#
|
441
|
-
# {Client#complete_multipart_upload},
|
442
|
-
# and {Client#upload_part} can be provided.
|
436
|
+
# Additional options for {Client#put_object} when file sizes below the multipart threshold.
|
437
|
+
# For files larger than the multipart threshold, options for {Client#create_multipart_upload},
|
438
|
+
# {Client#complete_multipart_upload}, and {Client#upload_part} can be provided.
|
443
439
|
#
|
444
|
-
# @option options [Integer] :multipart_threshold (104857600) Files larger
|
445
|
-
#
|
446
|
-
# multipart APIs.
|
447
|
-
# Default threshold is 100MB.
|
440
|
+
# @option options [Integer] :multipart_threshold (104857600) Files larger han or equal to
|
441
|
+
# `:multipart_threshold` are uploaded using the S3 multipart APIs. Default threshold is 100MB.
|
448
442
|
#
|
449
|
-
# @option options [Integer] :thread_count (10) The number of parallel
|
450
|
-
#
|
451
|
-
# `:multipart_threshold`.
|
443
|
+
# @option options [Integer] :thread_count (10) The number of parallel multipart uploads.
|
444
|
+
# This option is not used if the file is smaller than `:multipart_threshold`.
|
452
445
|
#
|
453
446
|
# @option options [Proc] :progress_callback
|
454
447
|
# A Proc that will be called when each chunk of the upload is sent.
|
455
448
|
# It will be invoked with [bytes_read], [total_sizes]
|
456
449
|
#
|
457
|
-
# @raise [MultipartUploadError] If an object is being uploaded in
|
458
|
-
#
|
459
|
-
#
|
460
|
-
# method that returns the failures that caused the upload to be
|
461
|
-
# aborted.
|
450
|
+
# @raise [MultipartUploadError] If an object is being uploaded in parts, and the upload can not be completed,
|
451
|
+
# then the upload is aborted and this error is raised. The raised error has a `#errors` method that
|
452
|
+
# returns the failures that caused the upload to be aborted.
|
462
453
|
#
|
463
|
-
# @return [Boolean] Returns `true` when the object is uploaded
|
464
|
-
# without any errors.
|
454
|
+
# @return [Boolean] Returns `true` when the object is uploaded without any errors.
|
465
455
|
#
|
466
456
|
# @see Client#put_object
|
467
457
|
# @see Client#create_multipart_upload
|
@@ -469,26 +459,21 @@ module Aws
|
|
469
459
|
# @see Client#upload_part
|
470
460
|
def upload_file(source, options = {})
|
471
461
|
uploading_options = options.dup
|
472
|
-
uploader = FileUploader.new(
|
473
|
-
multipart_threshold: uploading_options.delete(:multipart_threshold),
|
474
|
-
client: client
|
475
|
-
)
|
462
|
+
uploader = FileUploader.new(multipart_threshold: uploading_options.delete(:multipart_threshold), client: client)
|
476
463
|
response = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
477
|
-
uploader.upload(
|
478
|
-
source,
|
479
|
-
uploading_options.merge(bucket: bucket_name, key: key)
|
480
|
-
)
|
464
|
+
uploader.upload(source, uploading_options.merge(bucket: bucket_name, key: key))
|
481
465
|
end
|
482
466
|
yield response if block_given?
|
483
467
|
true
|
484
468
|
end
|
469
|
+
deprecated(:upload_file, use: 'Aws::S3::TransferManager#upload_file', version: 'next major version')
|
485
470
|
|
486
471
|
# Downloads a file in S3 to a path on disk.
|
487
472
|
#
|
488
473
|
# # small files (< 5MB) are downloaded in a single API call
|
489
474
|
# obj.download_file('/path/to/file')
|
490
475
|
#
|
491
|
-
# Files larger than 5MB are downloaded using multipart method
|
476
|
+
# Files larger than 5MB are downloaded using multipart method:
|
492
477
|
#
|
493
478
|
# # large files are split into parts
|
494
479
|
# # and the parts are downloaded in parallel
|
@@ -498,67 +483,63 @@ module Aws
|
|
498
483
|
#
|
499
484
|
# # bytes and part_sizes are each an array with 1 entry per part
|
500
485
|
# # part_sizes may not be known until the first bytes are retrieved
|
501
|
-
# progress =
|
502
|
-
# puts bytes.map.with_index { |b, i| "Part #{i+1}: #{b} / #{part_sizes[i]}"}.join(' ') + "Total: #{100.0 * bytes.sum / file_size}%"
|
486
|
+
# progress = proc do |bytes, part_sizes, file_size|
|
487
|
+
# puts bytes.map.with_index { |b, i| "Part #{i + 1}: #{b} / #{part_sizes[i]}" }.join(' ') + "Total: #{100.0 * bytes.sum / file_size}%"
|
503
488
|
# end
|
504
489
|
# obj.download_file('/path/to/file', progress_callback: progress)
|
505
490
|
#
|
506
|
-
# @param [String
|
491
|
+
# @param [String, Pathname, File, Tempfile] destination
|
492
|
+
# Where to download the file to. This can either be a String or Pathname to the file, an open File object,
|
493
|
+
# or an open Tempfile object. If you pass an open File or Tempfile object, then you are responsible for
|
494
|
+
# closing it after the download completes.
|
507
495
|
#
|
508
496
|
# @param [Hash] options
|
509
|
-
# Additional options for {Client#get_object} and #{Client#head_object}
|
510
|
-
# may be provided.
|
497
|
+
# Additional options for {Client#get_object} and #{Client#head_object} may be provided.
|
511
498
|
#
|
512
|
-
# @option options [String] mode `auto`, `single_request
|
513
|
-
# `single_request` mode forces only 1 GET request is made in download,
|
514
|
-
# `get_range` mode allows `chunk_size` parameter to configured in
|
515
|
-
# customizing each range size in multipart_download,
|
516
|
-
# By default, `auto` mode is enabled, which performs multipart_download
|
499
|
+
# @option options [String] :mode ("auto") `"auto"`, `"single_request"` or `"get_range"`
|
517
500
|
#
|
518
|
-
#
|
501
|
+
# * `auto` mode is enabled by default, which performs `multipart_download`
|
502
|
+
# * `"single_request`" mode forces only 1 GET request is made in download
|
503
|
+
# * `"get_range"` mode requires `:chunk_size` parameter to configured in customizing each range size
|
519
504
|
#
|
520
|
-
# @option options [Integer]
|
521
|
-
# the multipart download.
|
505
|
+
# @option options [Integer] :chunk_size required in `"get_range"` mode.
|
522
506
|
#
|
523
|
-
# @option options [
|
524
|
-
# retrieve the object. For more about object versioning, see:
|
525
|
-
# https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectVersioning.html
|
507
|
+
# @option options [Integer] :thread_count (10) Customize threads used in the multipart download.
|
526
508
|
#
|
527
|
-
# @option options [String]
|
528
|
-
# the object has a stored checksum, it will be used to validate the
|
529
|
-
# download and will raise an `Aws::Errors::ChecksumError` if
|
530
|
-
# checksum validation fails. You may provide a `on_checksum_validated`
|
531
|
-
# callback if you need to verify that validation occurred and which
|
532
|
-
# algorithm was used. To disable checksum validation, set
|
533
|
-
# `checksum_mode` to "DISABLED".
|
509
|
+
# @option options [String] :version_id The object version id used to retrieve the object.
|
534
510
|
#
|
535
|
-
#
|
536
|
-
#
|
537
|
-
#
|
538
|
-
#
|
511
|
+
# @see https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectVersioning.html ObjectVersioning
|
512
|
+
#
|
513
|
+
# @option options [String] :checksum_mode ("ENABLED")
|
514
|
+
# When `"ENABLED"` and the object has a stored checksum, it will be used to validate the download and will
|
515
|
+
# raise an `Aws::Errors::ChecksumError` if checksum validation fails. You may provide a `on_checksum_validated`
|
516
|
+
# callback if you need to verify that validation occurred and which algorithm was used.
|
517
|
+
# To disable checksum validation, set `checksum_mode` to `"DISABLED"`.
|
518
|
+
#
|
519
|
+
# @option options [Callable] :on_checksum_validated
|
520
|
+
# Called each time a request's checksum is validated with the checksum algorithm and the
|
521
|
+
# response. For multipart downloads, this will be called for each part that is downloaded and validated.
|
539
522
|
#
|
540
523
|
# @option options [Proc] :progress_callback
|
541
|
-
# A Proc that will be called when each chunk of the download is received.
|
542
|
-
#
|
543
|
-
#
|
544
|
-
#
|
545
|
-
# callback until the first bytes in the part are received.
|
524
|
+
# A Proc that will be called when each chunk of the download is received. It will be invoked with
|
525
|
+
# `bytes_read`, `part_sizes`, `file_size`. When the object is downloaded as parts (rather than by ranges),
|
526
|
+
# the `part_sizes` will not be known ahead of time and will be `nil` in the callback until the first bytes
|
527
|
+
# in the part are received.
|
546
528
|
#
|
547
|
-
# @
|
548
|
-
#
|
529
|
+
# @raise [MultipartDownloadError] Raised when an object validation fails outside of service errors.
|
530
|
+
#
|
531
|
+
# @return [Boolean] Returns `true` when the file is downloaded without any errors.
|
549
532
|
#
|
550
533
|
# @see Client#get_object
|
551
534
|
# @see Client#head_object
|
552
535
|
def download_file(destination, options = {})
|
553
536
|
downloader = FileDownloader.new(client: client)
|
554
537
|
Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
555
|
-
downloader.download(
|
556
|
-
destination,
|
557
|
-
options.merge(bucket: bucket_name, key: key)
|
558
|
-
)
|
538
|
+
downloader.download(destination, options.merge(bucket: bucket_name, key: key))
|
559
539
|
end
|
560
540
|
true
|
561
541
|
end
|
542
|
+
deprecated(:download_file, use: 'Aws::S3::TransferManager#download_file', version: 'next major version')
|
562
543
|
|
563
544
|
class Collection < Aws::Resources::Collection
|
564
545
|
alias_method :delete, :batch_delete!
|
@@ -10,6 +10,7 @@ module Aws
|
|
10
10
|
autoload :FileUploader, 'aws-sdk-s3/file_uploader'
|
11
11
|
autoload :FileDownloader, 'aws-sdk-s3/file_downloader'
|
12
12
|
autoload :LegacySigner, 'aws-sdk-s3/legacy_signer'
|
13
|
+
autoload :MultipartDownloadError, 'aws-sdk-s3/multipart_download_error'
|
13
14
|
autoload :MultipartFileUploader, 'aws-sdk-s3/multipart_file_uploader'
|
14
15
|
autoload :MultipartStreamUploader, 'aws-sdk-s3/multipart_stream_uploader'
|
15
16
|
autoload :MultipartUploadError, 'aws-sdk-s3/multipart_upload_error'
|
@@ -17,13 +18,13 @@ module Aws
|
|
17
18
|
autoload :ObjectMultipartCopier, 'aws-sdk-s3/object_multipart_copier'
|
18
19
|
autoload :PresignedPost, 'aws-sdk-s3/presigned_post'
|
19
20
|
autoload :Presigner, 'aws-sdk-s3/presigner'
|
21
|
+
autoload :TransferManager, 'aws-sdk-s3/transfer_manager'
|
20
22
|
|
21
23
|
# s3 express session auth
|
22
24
|
autoload :ExpressCredentials, 'aws-sdk-s3/express_credentials'
|
23
25
|
autoload :ExpressCredentialsProvider, 'aws-sdk-s3/express_credentials_provider'
|
24
26
|
|
25
27
|
# s3 access grants auth
|
26
|
-
|
27
28
|
autoload :AccessGrantsCredentials, 'aws-sdk-s3/access_grants_credentials'
|
28
29
|
autoload :AccessGrantsCredentialsProvider, 'aws-sdk-s3/access_grants_credentials_provider'
|
29
30
|
end
|