aws-sdk-s3 1.109.0 → 1.156.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 +352 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-s3/access_grants_credentials.rb +57 -0
- data/lib/aws-sdk-s3/access_grants_credentials_provider.rb +241 -0
- data/lib/aws-sdk-s3/bucket.rb +585 -110
- data/lib/aws-sdk-s3/bucket_acl.rb +28 -6
- data/lib/aws-sdk-s3/bucket_cors.rb +34 -10
- data/lib/aws-sdk-s3/bucket_lifecycle.rb +34 -10
- data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +34 -10
- data/lib/aws-sdk-s3/bucket_logging.rb +35 -6
- data/lib/aws-sdk-s3/bucket_notification.rb +12 -6
- data/lib/aws-sdk-s3/bucket_policy.rb +78 -10
- data/lib/aws-sdk-s3/bucket_region_cache.rb +9 -5
- data/lib/aws-sdk-s3/bucket_request_payment.rb +28 -6
- data/lib/aws-sdk-s3/bucket_tagging.rb +34 -10
- data/lib/aws-sdk-s3/bucket_versioning.rb +72 -14
- data/lib/aws-sdk-s3/bucket_website.rb +34 -10
- data/lib/aws-sdk-s3/client.rb +7900 -3252
- data/lib/aws-sdk-s3/client_api.rb +706 -228
- data/lib/aws-sdk-s3/customizations/bucket.rb +23 -47
- data/lib/aws-sdk-s3/customizations/errors.rb +40 -0
- data/lib/aws-sdk-s3/customizations/object.rb +97 -21
- data/lib/aws-sdk-s3/customizations/types/permanent_redirect.rb +26 -0
- data/lib/aws-sdk-s3/customizations.rb +10 -0
- data/lib/aws-sdk-s3/encryption/client.rb +6 -2
- data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +13 -9
- data/lib/aws-sdk-s3/encryptionV2/client.rb +6 -2
- data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +1 -0
- data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +10 -6
- data/lib/aws-sdk-s3/endpoint_parameters.rb +186 -0
- data/lib/aws-sdk-s3/endpoint_provider.rb +592 -0
- data/lib/aws-sdk-s3/endpoints.rb +2689 -0
- data/lib/aws-sdk-s3/express_credentials.rb +55 -0
- data/lib/aws-sdk-s3/express_credentials_provider.rb +59 -0
- data/lib/aws-sdk-s3/file_downloader.rb +170 -45
- data/lib/aws-sdk-s3/file_uploader.rb +11 -4
- data/lib/aws-sdk-s3/multipart_file_uploader.rb +30 -11
- data/lib/aws-sdk-s3/multipart_stream_uploader.rb +46 -17
- data/lib/aws-sdk-s3/multipart_upload.rb +194 -19
- data/lib/aws-sdk-s3/multipart_upload_part.rb +280 -30
- data/lib/aws-sdk-s3/object.rb +1753 -266
- data/lib/aws-sdk-s3/object_acl.rb +49 -13
- data/lib/aws-sdk-s3/object_copier.rb +7 -5
- data/lib/aws-sdk-s3/object_multipart_copier.rb +46 -22
- data/lib/aws-sdk-s3/object_summary.rb +1497 -221
- data/lib/aws-sdk-s3/object_version.rb +383 -58
- data/lib/aws-sdk-s3/plugins/accelerate.rb +3 -50
- data/lib/aws-sdk-s3/plugins/access_grants.rb +114 -0
- data/lib/aws-sdk-s3/plugins/arn.rb +0 -184
- data/lib/aws-sdk-s3/plugins/bucket_dns.rb +3 -39
- data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +1 -6
- data/lib/aws-sdk-s3/plugins/dualstack.rb +1 -49
- data/lib/aws-sdk-s3/plugins/endpoints.rb +274 -0
- data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +2 -1
- data/lib/aws-sdk-s3/plugins/express_session_auth.rb +97 -0
- data/lib/aws-sdk-s3/plugins/http_200_errors.rb +53 -16
- data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +6 -29
- data/lib/aws-sdk-s3/plugins/location_constraint.rb +3 -1
- data/lib/aws-sdk-s3/plugins/md5s.rb +6 -3
- data/lib/aws-sdk-s3/plugins/s3_signer.rb +42 -126
- data/lib/aws-sdk-s3/plugins/skip_whole_multipart_get_checksums.rb +31 -0
- data/lib/aws-sdk-s3/plugins/streaming_retry.rb +23 -2
- data/lib/aws-sdk-s3/presigned_post.rb +99 -78
- data/lib/aws-sdk-s3/presigner.rb +28 -37
- data/lib/aws-sdk-s3/resource.rb +89 -13
- data/lib/aws-sdk-s3/types.rb +6544 -4909
- data/lib/aws-sdk-s3.rb +5 -1
- data/sig/bucket.rbs +212 -0
- data/sig/bucket_acl.rbs +78 -0
- data/sig/bucket_cors.rbs +69 -0
- data/sig/bucket_lifecycle.rbs +88 -0
- data/sig/bucket_lifecycle_configuration.rbs +111 -0
- data/sig/bucket_logging.rbs +76 -0
- data/sig/bucket_notification.rbs +114 -0
- data/sig/bucket_policy.rbs +59 -0
- data/sig/bucket_request_payment.rbs +54 -0
- data/sig/bucket_tagging.rbs +65 -0
- data/sig/bucket_versioning.rbs +77 -0
- data/sig/bucket_website.rbs +93 -0
- data/sig/client.rbs +2381 -0
- data/sig/customizations/bucket.rbs +19 -0
- data/sig/customizations/object.rbs +38 -0
- data/sig/customizations/object_summary.rbs +35 -0
- data/sig/errors.rbs +34 -0
- data/sig/multipart_upload.rbs +110 -0
- data/sig/multipart_upload_part.rbs +105 -0
- data/sig/object.rbs +442 -0
- data/sig/object_acl.rbs +86 -0
- data/sig/object_summary.rbs +334 -0
- data/sig/object_version.rbs +137 -0
- data/sig/resource.rbs +127 -0
- data/sig/types.rbs +2568 -0
- data/sig/waiters.rbs +95 -0
- metadata +50 -16
- data/lib/aws-sdk-s3/arn/access_point_arn.rb +0 -69
- data/lib/aws-sdk-s3/arn/multi_region_access_point_arn.rb +0 -68
- data/lib/aws-sdk-s3/arn/object_lambda_arn.rb +0 -69
- data/lib/aws-sdk-s3/arn/outpost_access_point_arn.rb +0 -74
- data/lib/aws-sdk-s3/plugins/object_lambda_endpoint.rb +0 -25
@@ -5,22 +5,6 @@ require 'uri'
|
|
5
5
|
module Aws
|
6
6
|
module S3
|
7
7
|
class Bucket
|
8
|
-
# Save the old initialize method so that we can call 'super'.
|
9
|
-
old_initialize = instance_method(:initialize)
|
10
|
-
# Make the method redefinable
|
11
|
-
alias_method :initialize, :initialize
|
12
|
-
# Define a new initialize method that extracts out a bucket ARN.
|
13
|
-
define_method(:initialize) do |*args|
|
14
|
-
old_initialize.bind(self).call(*args)
|
15
|
-
resolved_region, arn = Plugins::ARN.resolve_arn!(
|
16
|
-
name,
|
17
|
-
client.config.region,
|
18
|
-
client.config.s3_use_arn_region
|
19
|
-
)
|
20
|
-
@resolved_region = resolved_region
|
21
|
-
@arn = arn
|
22
|
-
end
|
23
|
-
|
24
8
|
# Deletes all objects and versioned objects from this bucket
|
25
9
|
#
|
26
10
|
# @example
|
@@ -105,14 +89,27 @@ module Aws
|
|
105
89
|
if options[:virtual_host]
|
106
90
|
scheme = options.fetch(:secure, true) ? 'https' : 'http'
|
107
91
|
"#{scheme}://#{name}"
|
108
|
-
elsif @arn
|
109
|
-
Plugins::ARN.resolve_url!(
|
110
|
-
client.config.endpoint.dup,
|
111
|
-
@arn,
|
112
|
-
@resolved_region
|
113
|
-
).to_s
|
114
92
|
else
|
115
|
-
|
93
|
+
# Taken from Aws::S3::Endpoints module
|
94
|
+
unless client.config.regional_endpoint
|
95
|
+
endpoint = client.config.endpoint.to_s
|
96
|
+
end
|
97
|
+
params = Aws::S3::EndpointParameters.new(
|
98
|
+
bucket: name,
|
99
|
+
region: client.config.region,
|
100
|
+
use_fips: client.config.use_fips_endpoint,
|
101
|
+
use_dual_stack: client.config.use_dualstack_endpoint,
|
102
|
+
endpoint: endpoint,
|
103
|
+
force_path_style: client.config.force_path_style,
|
104
|
+
accelerate: client.config.use_accelerate_endpoint,
|
105
|
+
use_global_endpoint: client.config.s3_us_east_1_regional_endpoint == 'legacy',
|
106
|
+
use_object_lambda_endpoint: nil,
|
107
|
+
disable_access_points: nil,
|
108
|
+
disable_multi_region_access_points: client.config.s3_disable_multiregion_access_points,
|
109
|
+
use_arn_region: client.config.s3_use_arn_region,
|
110
|
+
)
|
111
|
+
endpoint = Aws::S3::EndpointProvider.new.resolve_endpoint(params)
|
112
|
+
endpoint.url
|
116
113
|
end
|
117
114
|
end
|
118
115
|
|
@@ -137,34 +134,13 @@ module Aws
|
|
137
134
|
|
138
135
|
# @api private
|
139
136
|
def load
|
140
|
-
@data =
|
137
|
+
@data = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
138
|
+
client.list_buckets.buckets.find { |b| b.name == name }
|
139
|
+
end
|
141
140
|
raise "unable to load bucket #{name}" if @data.nil?
|
142
141
|
|
143
142
|
self
|
144
143
|
end
|
145
|
-
|
146
|
-
private
|
147
|
-
|
148
|
-
def s3_bucket_url
|
149
|
-
url = client.config.endpoint.dup
|
150
|
-
if bucket_as_hostname?(url.scheme == 'https')
|
151
|
-
url.host = "#{name}.#{url.host}"
|
152
|
-
else
|
153
|
-
url.path += '/' unless url.path[-1] == '/'
|
154
|
-
url.path += Seahorse::Util.uri_escape(name)
|
155
|
-
end
|
156
|
-
if (client.config.region == 'us-east-1') &&
|
157
|
-
(client.config.s3_us_east_1_regional_endpoint == 'legacy')
|
158
|
-
url.host = Plugins::IADRegionalEndpoint.legacy_host(url.host)
|
159
|
-
end
|
160
|
-
url.to_s
|
161
|
-
end
|
162
|
-
|
163
|
-
def bucket_as_hostname?(https)
|
164
|
-
Plugins::BucketDns.dns_compatible?(name, https) &&
|
165
|
-
!client.config.force_path_style
|
166
|
-
end
|
167
|
-
|
168
144
|
end
|
169
145
|
end
|
170
146
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module S3
|
5
|
+
module Errors
|
6
|
+
# Hijack PermanentRedirect dynamic error to include the bucket, region,
|
7
|
+
# and endpoint.
|
8
|
+
class PermanentRedirect < ServiceError
|
9
|
+
# @param [Seahorse::Client::RequestContext] context
|
10
|
+
# @param [String] message
|
11
|
+
# @param [Aws::S3::Types::PermanentRedirect] _data
|
12
|
+
def initialize(context, message, _data = Aws::EmptyStructure.new)
|
13
|
+
data = Aws::S3::Types::PermanentRedirect.new(message: message)
|
14
|
+
body = context.http_response.body_contents
|
15
|
+
if (endpoint = body.match(/<Endpoint>(.+?)<\/Endpoint>/))
|
16
|
+
data.endpoint = endpoint[1]
|
17
|
+
end
|
18
|
+
if (bucket = body.match(/<Bucket>(.+?)<\/Bucket>/))
|
19
|
+
data.bucket = bucket[1]
|
20
|
+
end
|
21
|
+
data.region = context.http_response.headers['x-amz-bucket-region']
|
22
|
+
super(context, message, data)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Hijack PermanentRedirect (HeadBucket case - no body) dynamic error to
|
27
|
+
# include the region.
|
28
|
+
class Http301Error < ServiceError
|
29
|
+
# @param [Seahorse::Client::RequestContext] context
|
30
|
+
# @param [String] message
|
31
|
+
# @param [Aws::S3::Types::PermanentRedirect] _data
|
32
|
+
def initialize(context, message, _data = Aws::EmptyStructure.new)
|
33
|
+
data = Aws::S3::Types::PermanentRedirect.new(message: message)
|
34
|
+
data.region = context.http_response.headers['x-amz-bucket-region']
|
35
|
+
super(context, message, data)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -27,10 +27,13 @@ module Aws
|
|
27
27
|
# necessary for objects larger than 5GB and can provide
|
28
28
|
# performance improvements on large objects. Amazon S3 does
|
29
29
|
# not accept multipart copies for objects smaller than 5MB.
|
30
|
+
# Object metadata such as Content-Type will be copied, however,
|
31
|
+
# Checksums are not copied.
|
30
32
|
#
|
31
33
|
# @option options [Integer] :content_length Only used when
|
32
34
|
# `:multipart_copy` is `true`. Passing this options avoids a HEAD
|
33
|
-
# request to query the source object size
|
35
|
+
# request to query the source object size but prevents object metadata
|
36
|
+
# from being copied. Raises an `ArgumentError` if
|
34
37
|
# this option is provided when `:multipart_copy` is `false` or not set.
|
35
38
|
#
|
36
39
|
# @option options [S3::Client] :copy_source_client Only used when
|
@@ -43,6 +46,14 @@ module Aws
|
|
43
46
|
# different region. You do not need to specify this option
|
44
47
|
# if you have provided a `:source_client` or a `:content_length`.
|
45
48
|
#
|
49
|
+
# @option options [Boolean] :use_source_parts (false) Only used when
|
50
|
+
# `:multipart_copy` is `true`. Use part sizes defined on the source
|
51
|
+
# object if any exist. If copying or moving an object that
|
52
|
+
# is already multipart, this does not re-part the object, instead
|
53
|
+
# re-using the part definitions on the original. That means the etag
|
54
|
+
# and any checksums will not change. This is especially useful if the
|
55
|
+
# source object has parts with varied sizes.
|
56
|
+
#
|
46
57
|
# @example Basic object copy
|
47
58
|
#
|
48
59
|
# bucket = Aws::S3::Bucket.new('target-bucket')
|
@@ -65,11 +76,13 @@ module Aws
|
|
65
76
|
# @see #copy_to
|
66
77
|
#
|
67
78
|
def copy_from(source, options = {})
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
79
|
+
Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
80
|
+
if Hash === source && source[:copy_source]
|
81
|
+
# for backwards compatibility
|
82
|
+
@client.copy_object(source.merge(bucket: bucket_name, key: key))
|
83
|
+
else
|
84
|
+
ObjectCopier.new(self, options).copy_from(source, options)
|
85
|
+
end
|
73
86
|
end
|
74
87
|
end
|
75
88
|
|
@@ -106,7 +119,9 @@ module Aws
|
|
106
119
|
# object.copy_to('src-bucket/src-key', multipart_copy: true)
|
107
120
|
#
|
108
121
|
def copy_to(target, options = {})
|
109
|
-
|
122
|
+
Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
123
|
+
ObjectCopier.new(self, options).copy_to(target, options)
|
124
|
+
end
|
110
125
|
end
|
111
126
|
|
112
127
|
# Copies and deletes the current object. The object will only be deleted
|
@@ -338,6 +353,10 @@ module Aws
|
|
338
353
|
# obj.upload_stream do |write_stream|
|
339
354
|
# IO.copy_stream(STDIN, write_stream)
|
340
355
|
# end
|
356
|
+
# @param [Hash] options
|
357
|
+
# Additional options for {Client#create_multipart_upload},
|
358
|
+
# {Client#complete_multipart_upload},
|
359
|
+
# and {Client#upload_part} can be provided.
|
341
360
|
#
|
342
361
|
# @option options [Integer] :thread_count (10) The number of parallel
|
343
362
|
# multipart uploads
|
@@ -360,6 +379,9 @@ module Aws
|
|
360
379
|
# @return [Boolean] Returns `true` when the object is uploaded
|
361
380
|
# without any errors.
|
362
381
|
#
|
382
|
+
# @see Client#create_multipart_upload
|
383
|
+
# @see Client#complete_multipart_upload
|
384
|
+
# @see Client#upload_part
|
363
385
|
def upload_stream(options = {}, &block)
|
364
386
|
uploading_options = options.dup
|
365
387
|
uploader = MultipartStreamUploader.new(
|
@@ -368,10 +390,12 @@ module Aws
|
|
368
390
|
tempfile: uploading_options.delete(:tempfile),
|
369
391
|
part_size: uploading_options.delete(:part_size)
|
370
392
|
)
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
393
|
+
Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
394
|
+
uploader.upload(
|
395
|
+
uploading_options.merge(bucket: bucket_name, key: key),
|
396
|
+
&block
|
397
|
+
)
|
398
|
+
end
|
375
399
|
true
|
376
400
|
end
|
377
401
|
|
@@ -400,7 +424,7 @@ module Aws
|
|
400
424
|
# progress = Proc.new do |bytes, totals|
|
401
425
|
# puts bytes.map.with_index { |b, i| "Part #{i+1}: #{b} / #{totals[i]}"}.join(' ') + "Total: #{100.0 * bytes.sum / totals.sum }%" }
|
402
426
|
# end
|
403
|
-
# obj.upload_file('/path/to/file')
|
427
|
+
# obj.upload_file('/path/to/file', progress_callback: progress)
|
404
428
|
#
|
405
429
|
# @param [String, Pathname, File, Tempfile] source A file on the local
|
406
430
|
# file system that will be uploaded as this object. This can either be
|
@@ -410,6 +434,13 @@ module Aws
|
|
410
434
|
# using an open Tempfile, rewind it before uploading or else the object
|
411
435
|
# will be empty.
|
412
436
|
#
|
437
|
+
# @param [Hash] options
|
438
|
+
# Additional options for {Client#put_object}
|
439
|
+
# when file sizes below the multipart threshold. For files larger than
|
440
|
+
# the multipart threshold, options for {Client#create_multipart_upload},
|
441
|
+
# {Client#complete_multipart_upload},
|
442
|
+
# and {Client#upload_part} can be provided.
|
443
|
+
#
|
413
444
|
# @option options [Integer] :multipart_threshold (104857600) Files larger
|
414
445
|
# than or equal to `:multipart_threshold` are uploaded using the S3
|
415
446
|
# multipart APIs.
|
@@ -431,16 +462,23 @@ module Aws
|
|
431
462
|
#
|
432
463
|
# @return [Boolean] Returns `true` when the object is uploaded
|
433
464
|
# without any errors.
|
465
|
+
#
|
466
|
+
# @see Client#put_object
|
467
|
+
# @see Client#create_multipart_upload
|
468
|
+
# @see Client#complete_multipart_upload
|
469
|
+
# @see Client#upload_part
|
434
470
|
def upload_file(source, options = {})
|
435
471
|
uploading_options = options.dup
|
436
472
|
uploader = FileUploader.new(
|
437
473
|
multipart_threshold: uploading_options.delete(:multipart_threshold),
|
438
474
|
client: client
|
439
475
|
)
|
440
|
-
response =
|
441
|
-
|
442
|
-
|
443
|
-
|
476
|
+
response = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
477
|
+
uploader.upload(
|
478
|
+
source,
|
479
|
+
uploading_options.merge(bucket: bucket_name, key: key)
|
480
|
+
)
|
481
|
+
end
|
444
482
|
yield response if block_given?
|
445
483
|
true
|
446
484
|
end
|
@@ -456,15 +494,28 @@ module Aws
|
|
456
494
|
# # and the parts are downloaded in parallel
|
457
495
|
# obj.download_file('/path/to/very_large_file')
|
458
496
|
#
|
497
|
+
# You can provide a callback to monitor progress of the download:
|
498
|
+
#
|
499
|
+
# # bytes and part_sizes are each an array with 1 entry per part
|
500
|
+
# # part_sizes may not be known until the first bytes are retrieved
|
501
|
+
# progress = Proc.new do |bytes, part_sizes, file_size|
|
502
|
+
# puts bytes.map.with_index { |b, i| "Part #{i+1}: #{b} / #{part_sizes[i]}"}.join(' ') + "Total: #{100.0 * bytes.sum / file_size}%" }
|
503
|
+
# end
|
504
|
+
# obj.download_file('/path/to/file', progress_callback: progress)
|
505
|
+
#
|
459
506
|
# @param [String] destination Where to download the file to.
|
460
507
|
#
|
508
|
+
# @param [Hash] options
|
509
|
+
# Additional options for {Client#get_object} and #{Client#head_object}
|
510
|
+
# may be provided.
|
511
|
+
#
|
461
512
|
# @option options [String] mode `auto`, `single_request`, `get_range`
|
462
513
|
# `single_request` mode forces only 1 GET request is made in download,
|
463
514
|
# `get_range` mode allows `chunk_size` parameter to configured in
|
464
515
|
# customizing each range size in multipart_download,
|
465
516
|
# By default, `auto` mode is enabled, which performs multipart_download
|
466
517
|
#
|
467
|
-
# @option options [
|
518
|
+
# @option options [Integer] chunk_size required in get_range mode.
|
468
519
|
#
|
469
520
|
# @option options [Integer] thread_count (10) Customize threads used in
|
470
521
|
# the multipart download.
|
@@ -473,14 +524,39 @@ module Aws
|
|
473
524
|
# retrieve the object. For more about object versioning, see:
|
474
525
|
# https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectVersioning.html
|
475
526
|
#
|
527
|
+
# @option options [String] checksum_mode (ENABLED) When `ENABLED` and
|
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".
|
534
|
+
#
|
535
|
+
# @option options [Callable] on_checksum_validated Called each time a
|
536
|
+
# request's checksum is validated with the checksum algorithm and the
|
537
|
+
# response. For multipart downloads, this will be called for each
|
538
|
+
# part that is downloaded and validated.
|
539
|
+
#
|
540
|
+
# @option options [Proc] :progress_callback
|
541
|
+
# A Proc that will be called when each chunk of the download is received.
|
542
|
+
# It will be invoked with [bytes_read], [part_sizes], file_size.
|
543
|
+
# When the object is downloaded as parts (rather than by ranges), the
|
544
|
+
# part_sizes will not be known ahead of time and will be nil in the
|
545
|
+
# callback until the first bytes in the part are received.
|
546
|
+
#
|
476
547
|
# @return [Boolean] Returns `true` when the file is downloaded without
|
477
548
|
# any errors.
|
549
|
+
#
|
550
|
+
# @see Client#get_object
|
551
|
+
# @see Client#head_object
|
478
552
|
def download_file(destination, options = {})
|
479
553
|
downloader = FileDownloader.new(client: client)
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
554
|
+
Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
555
|
+
downloader.download(
|
556
|
+
destination,
|
557
|
+
options.merge(bucket: bucket_name, key: key)
|
558
|
+
)
|
559
|
+
end
|
484
560
|
true
|
485
561
|
end
|
486
562
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module S3
|
5
|
+
module Types
|
6
|
+
# This error is not modeled.
|
7
|
+
#
|
8
|
+
# The bucket you are attempting to access must be addressed using the
|
9
|
+
# specified endpoint. Please send all future requests to this endpoint.
|
10
|
+
#
|
11
|
+
# @!attribute [rw] endpoint
|
12
|
+
# @return [String]
|
13
|
+
#
|
14
|
+
# @!attribute [rw] bucket
|
15
|
+
# @return [String]
|
16
|
+
#
|
17
|
+
# @!attribute [rw] message
|
18
|
+
# @return [String]
|
19
|
+
#
|
20
|
+
class PermanentRedirect < Struct.new(:endpoint, :bucket, :region, :message)
|
21
|
+
SENSITIVE = []
|
22
|
+
include Aws::Structure
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -16,12 +16,22 @@ require 'aws-sdk-s3/object_multipart_copier'
|
|
16
16
|
require 'aws-sdk-s3/presigned_post'
|
17
17
|
require 'aws-sdk-s3/presigner'
|
18
18
|
|
19
|
+
# s3 express session auth
|
20
|
+
require 'aws-sdk-s3/express_credentials'
|
21
|
+
require 'aws-sdk-s3/express_credentials_provider'
|
22
|
+
|
23
|
+
# s3 access grants auth
|
24
|
+
require 'aws-sdk-s3/access_grants_credentials'
|
25
|
+
require 'aws-sdk-s3/access_grants_credentials_provider'
|
26
|
+
|
19
27
|
# customizations to generated classes
|
20
28
|
require 'aws-sdk-s3/customizations/bucket'
|
29
|
+
require 'aws-sdk-s3/customizations/errors'
|
21
30
|
require 'aws-sdk-s3/customizations/object'
|
22
31
|
require 'aws-sdk-s3/customizations/object_summary'
|
23
32
|
require 'aws-sdk-s3/customizations/multipart_upload'
|
24
33
|
require 'aws-sdk-s3/customizations/types/list_object_versions_output'
|
34
|
+
require 'aws-sdk-s3/customizations/types/permanent_redirect'
|
25
35
|
|
26
36
|
[
|
27
37
|
Aws::S3::Object::Collection,
|
@@ -270,7 +270,9 @@ module Aws
|
|
270
270
|
envelope_location: @envelope_location,
|
271
271
|
instruction_file_suffix: @instruction_file_suffix,
|
272
272
|
}
|
273
|
-
|
273
|
+
Aws::Plugins::UserAgent.metric('S3_CRYPTO_V1N') do
|
274
|
+
req.send_request
|
275
|
+
end
|
274
276
|
end
|
275
277
|
|
276
278
|
# Gets an object from Amazon S3, decrypting data locally.
|
@@ -298,7 +300,9 @@ module Aws
|
|
298
300
|
envelope_location: envelope_location,
|
299
301
|
instruction_file_suffix: instruction_file_suffix,
|
300
302
|
}
|
301
|
-
|
303
|
+
Aws::Plugins::UserAgent.metric('S3_CRYPTO_V1N') do
|
304
|
+
req.send_request(target: block)
|
305
|
+
end
|
302
306
|
end
|
303
307
|
|
304
308
|
private
|
@@ -17,11 +17,13 @@ module Aws
|
|
17
17
|
# envelope and encryption cipher.
|
18
18
|
def encryption_cipher
|
19
19
|
encryption_context = { "kms_cmk_id" => @kms_key_id }
|
20
|
-
key_data =
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
key_data = Aws::Plugins::UserAgent.metric('S3_CRYPTO_V1N') do
|
21
|
+
@kms_client.generate_data_key(
|
22
|
+
key_id: @kms_key_id,
|
23
|
+
encryption_context: encryption_context,
|
24
|
+
key_spec: 'AES_256'
|
25
|
+
)
|
26
|
+
end
|
25
27
|
cipher = Utils.aes_encryption_cipher(:CBC)
|
26
28
|
cipher.key = key_data.plaintext
|
27
29
|
envelope = {
|
@@ -58,10 +60,12 @@ module Aws
|
|
58
60
|
"#{envelope['x-amz-wrap-alg']}"
|
59
61
|
end
|
60
62
|
|
61
|
-
key =
|
62
|
-
|
63
|
-
|
64
|
-
|
63
|
+
key = Aws::Plugins::UserAgent.metric('S3_CRYPTO_V1N') do
|
64
|
+
@kms_client.decrypt(
|
65
|
+
ciphertext_blob: decode64(envelope['x-amz-key-v2']),
|
66
|
+
encryption_context: encryption_context
|
67
|
+
).plaintext
|
68
|
+
end
|
65
69
|
|
66
70
|
iv = decode64(envelope['x-amz-iv'])
|
67
71
|
block_mode =
|
@@ -361,7 +361,9 @@ module Aws
|
|
361
361
|
instruction_file_suffix: @instruction_file_suffix,
|
362
362
|
kms_encryption_context: kms_encryption_context
|
363
363
|
}
|
364
|
-
|
364
|
+
Aws::Plugins::UserAgent.metric('S3_CRYPTO_V2') do
|
365
|
+
req.send_request
|
366
|
+
end
|
365
367
|
end
|
366
368
|
|
367
369
|
# Gets an object from Amazon S3, decrypting data locally.
|
@@ -414,7 +416,9 @@ module Aws
|
|
414
416
|
kms_allow_decrypt_with_any_cmk: kms_any_cmk_mode,
|
415
417
|
security_profile: security_profile
|
416
418
|
}
|
417
|
-
|
419
|
+
Aws::Plugins::UserAgent.metric('S3_CRYPTO_V2') do
|
420
|
+
req.send_request(target: block)
|
421
|
+
end
|
418
422
|
end
|
419
423
|
|
420
424
|
private
|
@@ -24,11 +24,13 @@ module Aws
|
|
24
24
|
def encryption_cipher(options = {})
|
25
25
|
validate_key_for_encryption
|
26
26
|
encryption_context = build_encryption_context(@content_encryption_schema, options)
|
27
|
-
key_data =
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
key_data = Aws::Plugins::UserAgent.metric('S3_CRYPTO_V2') do
|
28
|
+
@kms_client.generate_data_key(
|
29
|
+
key_id: @kms_key_id,
|
30
|
+
encryption_context: encryption_context,
|
31
|
+
key_spec: 'AES_256'
|
32
|
+
)
|
33
|
+
end
|
32
34
|
cipher = Utils.aes_encryption_cipher(:GCM)
|
33
35
|
cipher.key = key_data.plaintext
|
34
36
|
envelope = {
|
@@ -83,7 +85,9 @@ module Aws
|
|
83
85
|
decrypt_options[:key_id] = @kms_key_id
|
84
86
|
end
|
85
87
|
|
86
|
-
key =
|
88
|
+
key = Aws::Plugins::UserAgent.metric('S3_CRYPTO_V2') do
|
89
|
+
@kms_client.decrypt(decrypt_options).plaintext
|
90
|
+
end
|
87
91
|
iv = decode64(envelope['x-amz-iv'])
|
88
92
|
block_mode =
|
89
93
|
case cek_alg
|