aws-sdk-s3 1.71.1 → 1.76.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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/aws-sdk-s3.rb +1 -1
  3. data/lib/aws-sdk-s3/bucket.rb +2 -2
  4. data/lib/aws-sdk-s3/client.rb +795 -507
  5. data/lib/aws-sdk-s3/customizations/object.rb +12 -1
  6. data/lib/aws-sdk-s3/encryption.rb +2 -0
  7. data/lib/aws-sdk-s3/encryption/client.rb +11 -0
  8. data/lib/aws-sdk-s3/encryption/decrypt_handler.rb +52 -28
  9. data/lib/aws-sdk-s3/encryption/default_cipher_provider.rb +41 -5
  10. data/lib/aws-sdk-s3/encryption/encrypt_handler.rb +5 -5
  11. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +32 -3
  12. data/lib/aws-sdk-s3/encryption/utils.rb +23 -0
  13. data/lib/aws-sdk-s3/encryptionV2/client.rb +198 -22
  14. data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +40 -12
  15. data/lib/aws-sdk-s3/encryptionV2/default_cipher_provider.rb +77 -10
  16. data/lib/aws-sdk-s3/encryptionV2/default_key_provider.rb +2 -0
  17. data/lib/aws-sdk-s3/encryptionV2/encrypt_handler.rb +7 -4
  18. data/lib/aws-sdk-s3/encryptionV2/errors.rb +24 -0
  19. data/lib/aws-sdk-s3/encryptionV2/io_auth_decrypter.rb +2 -0
  20. data/lib/aws-sdk-s3/encryptionV2/io_decrypter.rb +2 -0
  21. data/lib/aws-sdk-s3/encryptionV2/io_encrypter.rb +2 -0
  22. data/lib/aws-sdk-s3/encryptionV2/key_provider.rb +2 -0
  23. data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +90 -20
  24. data/lib/aws-sdk-s3/encryptionV2/materials.rb +2 -0
  25. data/lib/aws-sdk-s3/encryptionV2/utils.rb +2 -15
  26. data/lib/aws-sdk-s3/encryption_v2.rb +4 -1
  27. data/lib/aws-sdk-s3/file_uploader.rb +11 -0
  28. data/lib/aws-sdk-s3/multipart_file_uploader.rb +37 -2
  29. data/lib/aws-sdk-s3/multipart_upload_part.rb +5 -5
  30. data/lib/aws-sdk-s3/object.rb +10 -9
  31. data/lib/aws-sdk-s3/object_summary.rb +23 -7
  32. data/lib/aws-sdk-s3/object_version.rb +2 -2
  33. data/lib/aws-sdk-s3/plugins/accelerate.rb +27 -38
  34. data/lib/aws-sdk-s3/plugins/dualstack.rb +3 -1
  35. data/lib/aws-sdk-s3/plugins/sse_cpk.rb +1 -1
  36. data/lib/aws-sdk-s3/presigned_post.rb +61 -28
  37. data/lib/aws-sdk-s3/presigner.rb +2 -2
  38. data/lib/aws-sdk-s3/types.rb +63 -26
  39. metadata +9 -8
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'base64'
2
4
 
3
5
  module Aws
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'openssl'
2
4
 
3
5
  module Aws
@@ -6,24 +8,9 @@ module Aws
6
8
  # @api private
7
9
  module Utils
8
10
 
9
- UNSAFE_MSG = "unsafe encryption, data is longer than key length"
10
-
11
11
  class << self
12
12
 
13
- def encrypt(key, data)
14
- case key
15
- when OpenSSL::PKey::RSA # asymmetric encryption
16
- warn(UNSAFE_MSG) if key.public_key.n.num_bits < cipher_size(data)
17
- key.public_encrypt(data)
18
- when String # symmetric encryption
19
- warn(UNSAFE_MSG) if cipher_size(key) < cipher_size(data)
20
- cipher = aes_encryption_cipher(:ECB, key)
21
- cipher.update(data) + cipher.final
22
- end
23
- end
24
-
25
13
  def encrypt_aes_gcm(key, data, auth_data)
26
- warn(UNSAFE_MSG) if cipher_size(key) < cipher_size(data)
27
14
  cipher = aes_encryption_cipher(:GCM, key)
28
15
  cipher.iv = (iv = cipher.random_iv)
29
16
  cipher.auth_data = auth_data
@@ -14,7 +14,10 @@ require 'aws-sdk-s3/encryptionV2/default_key_provider'
14
14
 
15
15
  module Aws
16
16
  module S3
17
- module EncryptionV2; end
17
+ module EncryptionV2
18
+ AES_GCM_TAG_LEN_BYTES = 16
19
+ EC_USER_AGENT = 'S3CryptoV2'
20
+ end
18
21
  end
19
22
  end
20
23
 
@@ -29,6 +29,9 @@ module Aws
29
29
  # @param [String, Pathname, File, Tempfile] source The file to upload.
30
30
  # @option options [required, String] :bucket The bucket to upload to.
31
31
  # @option options [required, String] :key The key for the object.
32
+ # @option options [Proc] :progress_callback
33
+ # A Proc that will be called when each chunk of the upload is sent.
34
+ # It will be invoked with [bytes_read], [total_sizes]
32
35
  # @return [void]
33
36
  def upload(source, options = {})
34
37
  if File.size(source) >= multipart_threshold
@@ -49,11 +52,19 @@ module Aws
49
52
  end
50
53
 
51
54
  def put_object(source, options)
55
+ if (callback = options.delete(:progress_callback))
56
+ options[:on_chunk_sent] = single_part_progress(callback)
57
+ end
52
58
  open_file(source) do |file|
53
59
  @client.put_object(options.merge(body: file))
54
60
  end
55
61
  end
56
62
 
63
+ def single_part_progress(progress_callback)
64
+ proc do |_chunk, bytes_read, total_size|
65
+ progress_callback.call([bytes_read], [total_size])
66
+ end
67
+ end
57
68
  end
58
69
  end
59
70
  end
@@ -39,6 +39,9 @@ module Aws
39
39
  # @param [String, Pathname, File, Tempfile] source The file to upload.
40
40
  # @option options [required, String] :bucket The bucket to upload to.
41
41
  # @option options [required, String] :key The key for the object.
42
+ # @option options [Proc] :progress_callback
43
+ # A Proc that will be called when each chunk of the upload is sent.
44
+ # It will be invoked with [bytes_read], [total_sizes]
42
45
  # @return [void]
43
46
  def upload(source, options = {})
44
47
  if File.size(source) < MIN_PART_SIZE
@@ -68,7 +71,7 @@ module Aws
68
71
  def upload_parts(upload_id, source, options)
69
72
  pending = PartList.new(compute_parts(upload_id, source, options))
70
73
  completed = PartList.new
71
- errors = upload_in_threads(pending, completed)
74
+ errors = upload_in_threads(pending, completed, options)
72
75
  if errors.empty?
73
76
  completed.to_a.sort_by { |part| part[:part_number] }
74
77
  else
@@ -127,12 +130,21 @@ module Aws
127
130
  end
128
131
  end
129
132
 
130
- def upload_in_threads(pending, completed)
133
+ def upload_in_threads(pending, completed, options)
131
134
  threads = []
135
+ if (callback = options[:progress_callback])
136
+ progress = MultipartProgress.new(pending, callback)
137
+ end
132
138
  @thread_count.times do
133
139
  thread = Thread.new do
134
140
  begin
135
141
  while part = pending.shift
142
+ if progress
143
+ part[:on_chunk_sent] =
144
+ proc do |_chunk, bytes, _total|
145
+ progress.call(part[:part_number], bytes)
146
+ end
147
+ end
136
148
  resp = @client.upload_part(part)
137
149
  part[:body].close
138
150
  completed.push(etag: resp.etag, part_number: part[:part_number])
@@ -182,11 +194,34 @@ module Aws
182
194
  @mutex.synchronize { @parts.clear }
183
195
  end
184
196
 
197
+ def size
198
+ @mutex.synchronize { @parts.size }
199
+ end
200
+
201
+ def part_sizes
202
+ @mutex.synchronize { @parts.map { |p| p[:body].size } }
203
+ end
204
+
185
205
  def to_a
186
206
  @mutex.synchronize { @parts.dup }
187
207
  end
188
208
 
189
209
  end
210
+
211
+ # @api private
212
+ class MultipartProgress
213
+ def initialize(parts, progress_callback)
214
+ @bytes_sent = Array.new(parts.size, 0)
215
+ @total_sizes = parts.part_sizes
216
+ @progress_callback = progress_callback
217
+ end
218
+
219
+ def call(part_number, bytes_read)
220
+ # part numbers start at 1
221
+ @bytes_sent[part_number - 1] = bytes_read
222
+ @progress_callback.call(@bytes_sent, @total_sizes)
223
+ end
224
+ end
190
225
  end
191
226
  end
192
227
  end
@@ -250,8 +250,8 @@ module Aws::S3
250
250
  # encrypting data. This value is used to store the object and then it is
251
251
  # discarded; Amazon S3 does not store the encryption key. The key must
252
252
  # be appropriate for use with the algorithm specified in the
253
- # `x-amz-server-side​-encryption​-customer-algorithm` header. This must
254
- # be the same encryption key specified in the initiate multipart upload
253
+ # `x-amz-server-side-encryption-customer-algorithm` header. This must be
254
+ # the same encryption key specified in the initiate multipart upload
255
255
  # request.
256
256
  # @option options [String] :sse_customer_key_md5
257
257
  # Specifies the 128-bit MD5 digest of the encryption key according to
@@ -302,7 +302,7 @@ module Aws::S3
302
302
  # request_payer: "requester", # accepts requester
303
303
  # })
304
304
  # @param [Hash] options ({})
305
- # @option options [String, IO] :body
305
+ # @option options [String, StringIO, File] :body
306
306
  # Object data.
307
307
  # @option options [Integer] :content_length
308
308
  # Size of the body in bytes. This parameter is useful when the size of
@@ -319,8 +319,8 @@ module Aws::S3
319
319
  # encrypting data. This value is used to store the object and then it is
320
320
  # discarded; Amazon S3 does not store the encryption key. The key must
321
321
  # be appropriate for use with the algorithm specified in the
322
- # `x-amz-server-side​-encryption​-customer-algorithm header`. This must
323
- # be the same encryption key specified in the initiate multipart upload
322
+ # `x-amz-server-side-encryption-customer-algorithm header`. This must be
323
+ # the same encryption key specified in the initiate multipart upload
324
324
  # request.
325
325
  # @option options [String] :sse_customer_key_md5
326
326
  # Specifies the 128-bit MD5 digest of the encryption key according to
@@ -67,8 +67,8 @@ module Aws::S3
67
67
 
68
68
  # If the object is an archived object (an object whose storage class is
69
69
  # GLACIER), the response includes this header if either the archive
70
- # restoration is in progress (see RestoreObject or an archive copy is
71
- # already restored.
70
+ # restoration is in progress (see [RestoreObject][1] or an archive copy
71
+ # is already restored.
72
72
  #
73
73
  # If an archive copy is already restored, the header value indicates
74
74
  # when Amazon S3 is scheduled to delete the object copy. For example:
@@ -80,11 +80,12 @@ module Aws::S3
80
80
  # `ongoing-request="true"`.
81
81
  #
82
82
  # For more information about archiving objects, see [Transitioning
83
- # Objects: General Considerations][1].
83
+ # Objects: General Considerations][2].
84
84
  #
85
85
  #
86
86
  #
87
- # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html#lifecycle-transition-general-considerations
87
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_RestoreObject.html
88
+ # [2]: https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html#lifecycle-transition-general-considerations
88
89
  # @return [String]
89
90
  def restore
90
91
  data[:restore]
@@ -609,7 +610,7 @@ module Aws::S3
609
610
  # encrypting data. This value is used to store the object and then it is
610
611
  # discarded; Amazon S3 does not store the encryption key. The key must
611
612
  # be appropriate for use with the algorithm specified in the
612
- # `x-amz-server-side​-encryption​-customer-algorithm` header.
613
+ # `x-amz-server-side-encryption-customer-algorithm` header.
613
614
  # @option options [String] :sse_customer_key_md5
614
615
  # Specifies the 128-bit MD5 digest of the encryption key according to
615
616
  # RFC 1321. Amazon S3 uses this header for a message integrity check to
@@ -779,7 +780,7 @@ module Aws::S3
779
780
  # encrypting data. This value is used to store the object and then it is
780
781
  # discarded; Amazon S3 does not store the encryption key. The key must
781
782
  # be appropriate for use with the algorithm specified in the
782
- # `x-amz-server-side​-encryption​-customer-algorithm` header.
783
+ # `x-amz-server-side-encryption-customer-algorithm` header.
783
784
  # @option options [String] :sse_customer_key_md5
784
785
  # Specifies the 128-bit MD5 digest of the encryption key according to
785
786
  # RFC 1321. Amazon S3 uses this header for a message integrity check to
@@ -885,7 +886,7 @@ module Aws::S3
885
886
  # encrypting data. This value is used to store the object and then it is
886
887
  # discarded; Amazon S3 does not store the encryption key. The key must
887
888
  # be appropriate for use with the algorithm specified in the
888
- # `x-amz-server-side​-encryption​-customer-algorithm` header.
889
+ # `x-amz-server-side-encryption-customer-algorithm` header.
889
890
  # @option options [String] :sse_customer_key_md5
890
891
  # Specifies the 128-bit MD5 digest of the encryption key according to
891
892
  # RFC 1321. Amazon S3 uses this header for a message integrity check to
@@ -983,7 +984,7 @@ module Aws::S3
983
984
  #
984
985
  #
985
986
  # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#CannedACL
986
- # @option options [String, IO] :body
987
+ # @option options [String, StringIO, File] :body
987
988
  # Object data.
988
989
  # @option options [String] :cache_control
989
990
  # Can be used to specify caching behavior along the request/reply chain.
@@ -1098,7 +1099,7 @@ module Aws::S3
1098
1099
  # encrypting data. This value is used to store the object and then it is
1099
1100
  # discarded; Amazon S3 does not store the encryption key. The key must
1100
1101
  # be appropriate for use with the algorithm specified in the
1101
- # `x-amz-server-side​-encryption​-customer-algorithm` header.
1102
+ # `x-amz-server-side-encryption-customer-algorithm` header.
1102
1103
  # @option options [String] :sse_customer_key_md5
1103
1104
  # Specifies the 128-bit MD5 digest of the encryption key according to
1104
1105
  # RFC 1321. Amazon S3 uses this header for a message integrity check to
@@ -48,8 +48,24 @@ module Aws::S3
48
48
  data[:last_modified]
49
49
  end
50
50
 
51
- # The entity tag is an MD5 hash of the object. ETag reflects only
52
- # changes to the contents of an object, not its metadata.
51
+ # The entity tag is a hash of the object. The ETag reflects changes only
52
+ # to the contents of an object, not its metadata. The ETag may or may
53
+ # not be an MD5 digest of the object data. Whether or not it is depends
54
+ # on how the object was created and how it is encrypted as described
55
+ # below:
56
+ #
57
+ # * Objects created by the PUT Object, POST Object, or Copy operation,
58
+ # or through the AWS Management Console, and are encrypted by SSE-S3
59
+ # or plaintext, have ETags that are an MD5 digest of their object
60
+ # data.
61
+ #
62
+ # * Objects created by the PUT Object, POST Object, or Copy operation,
63
+ # or through the AWS Management Console, and are encrypted by SSE-C or
64
+ # SSE-KMS, have ETags that are not an MD5 digest of their object data.
65
+ #
66
+ # * If an object is created by either the Multipart Upload or Part Copy
67
+ # operation, the ETag is not an MD5 digest, regardless of the method
68
+ # of encryption.
53
69
  # @return [String]
54
70
  def etag
55
71
  data[:etag]
@@ -359,7 +375,7 @@ module Aws::S3
359
375
  # encrypting data. This value is used to store the object and then it is
360
376
  # discarded; Amazon S3 does not store the encryption key. The key must
361
377
  # be appropriate for use with the algorithm specified in the
362
- # `x-amz-server-side​-encryption​-customer-algorithm` header.
378
+ # `x-amz-server-side-encryption-customer-algorithm` header.
363
379
  # @option options [String] :sse_customer_key_md5
364
380
  # Specifies the 128-bit MD5 digest of the encryption key according to
365
381
  # RFC 1321. Amazon S3 uses this header for a message integrity check to
@@ -529,7 +545,7 @@ module Aws::S3
529
545
  # encrypting data. This value is used to store the object and then it is
530
546
  # discarded; Amazon S3 does not store the encryption key. The key must
531
547
  # be appropriate for use with the algorithm specified in the
532
- # `x-amz-server-side​-encryption​-customer-algorithm` header.
548
+ # `x-amz-server-side-encryption-customer-algorithm` header.
533
549
  # @option options [String] :sse_customer_key_md5
534
550
  # Specifies the 128-bit MD5 digest of the encryption key according to
535
551
  # RFC 1321. Amazon S3 uses this header for a message integrity check to
@@ -635,7 +651,7 @@ module Aws::S3
635
651
  # encrypting data. This value is used to store the object and then it is
636
652
  # discarded; Amazon S3 does not store the encryption key. The key must
637
653
  # be appropriate for use with the algorithm specified in the
638
- # `x-amz-server-side​-encryption​-customer-algorithm` header.
654
+ # `x-amz-server-side-encryption-customer-algorithm` header.
639
655
  # @option options [String] :sse_customer_key_md5
640
656
  # Specifies the 128-bit MD5 digest of the encryption key according to
641
657
  # RFC 1321. Amazon S3 uses this header for a message integrity check to
@@ -733,7 +749,7 @@ module Aws::S3
733
749
  #
734
750
  #
735
751
  # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#CannedACL
736
- # @option options [String, IO] :body
752
+ # @option options [String, StringIO, File] :body
737
753
  # Object data.
738
754
  # @option options [String] :cache_control
739
755
  # Can be used to specify caching behavior along the request/reply chain.
@@ -848,7 +864,7 @@ module Aws::S3
848
864
  # encrypting data. This value is used to store the object and then it is
849
865
  # discarded; Amazon S3 does not store the encryption key. The key must
850
866
  # be appropriate for use with the algorithm specified in the
851
- # `x-amz-server-side​-encryption​-customer-algorithm` header.
867
+ # `x-amz-server-side-encryption-customer-algorithm` header.
852
868
  # @option options [String] :sse_customer_key_md5
853
869
  # Specifies the 128-bit MD5 digest of the encryption key according to
854
870
  # RFC 1321. Amazon S3 uses this header for a message integrity check to
@@ -331,7 +331,7 @@ module Aws::S3
331
331
  # encrypting data. This value is used to store the object and then it is
332
332
  # discarded; Amazon S3 does not store the encryption key. The key must
333
333
  # be appropriate for use with the algorithm specified in the
334
- # `x-amz-server-side​-encryption​-customer-algorithm` header.
334
+ # `x-amz-server-side-encryption-customer-algorithm` header.
335
335
  # @option options [String] :sse_customer_key_md5
336
336
  # Specifies the 128-bit MD5 digest of the encryption key according to
337
337
  # RFC 1321. Amazon S3 uses this header for a message integrity check to
@@ -406,7 +406,7 @@ module Aws::S3
406
406
  # encrypting data. This value is used to store the object and then it is
407
407
  # discarded; Amazon S3 does not store the encryption key. The key must
408
408
  # be appropriate for use with the algorithm specified in the
409
- # `x-amz-server-side​-encryption​-customer-algorithm` header.
409
+ # `x-amz-server-side-encryption-customer-algorithm` header.
410
410
  # @option options [String] :sse_customer_key_md5
411
411
  # Specifies the 128-bit MD5 digest of the encryption key according to
412
412
  # RFC 1321. Amazon S3 uses this header for a message integrity check to
@@ -3,36 +3,46 @@
3
3
  module Aws
4
4
  module S3
5
5
  module Plugins
6
-
7
6
  # Provides support for using `Aws::S3::Client` with Amazon S3 Transfer
8
7
  # Acceleration.
9
8
  #
10
9
  # Go here for more information about transfer acceleration:
11
10
  # [http://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html](http://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html)
12
11
  class Accelerate < Seahorse::Client::Plugin
13
-
14
- option(:use_accelerate_endpoint,
12
+ option(
13
+ :use_accelerate_endpoint,
15
14
  default: false,
16
15
  doc_type: 'Boolean',
17
16
  docstring: <<-DOCS)
18
17
  When set to `true`, accelerated bucket endpoints will be used
19
18
  for all object operations. You must first enable accelerate for
20
- each bucket. [Go here for more information](http://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html).
19
+ each bucket. [Go here for more information](http://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html).
21
20
  DOCS
22
21
 
23
22
  def add_handlers(handlers, config)
24
23
  operations = config.api.operation_names - [
25
- :create_bucket, :list_buckets, :delete_bucket,
24
+ :create_bucket, :list_buckets, :delete_bucket
26
25
  ]
27
- handlers.add(OptionHandler, step: :initialize, operations: operations)
28
- handlers.add(AccelerateHandler, step: :build, priority: 0, operations: operations)
26
+ # Need 2 handlers so that the context can be set for other plugins
27
+ # and to remove :use_accelerate_endpoint from the params.
28
+ handlers.add(
29
+ OptionHandler, step: :initialize, operations: operations
30
+ )
31
+ handlers.add(
32
+ AccelerateHandler, step: :build, priority: 0, operations: operations
33
+ )
29
34
  end
30
35
 
31
36
  # @api private
32
37
  class OptionHandler < Seahorse::Client::Handler
33
38
  def call(context)
34
- accelerate = context.params.delete(:use_accelerate_endpoint)
35
- accelerate = context.config.use_accelerate_endpoint if accelerate.nil?
39
+ # Support client configuration and per-operation configuration
40
+ if context.params.is_a?(Hash)
41
+ accelerate = context.params.delete(:use_accelerate_endpoint)
42
+ end
43
+ if accelerate.nil?
44
+ accelerate = context.config.use_accelerate_endpoint
45
+ end
36
46
  context[:use_accelerate_endpoint] = accelerate
37
47
  @handler.call(context)
38
48
  end
@@ -40,39 +50,24 @@ each bucket. [Go here for more information](http://docs.aws.amazon.com/AmazonS3
40
50
 
41
51
  # @api private
42
52
  class AccelerateHandler < Seahorse::Client::Handler
43
-
44
53
  def call(context)
45
54
  if context[:use_accelerate_endpoint]
46
- if context[:use_dualstack_endpoint]
47
- use_combined_accelerate_dualstack_endpoint(context)
48
- else
49
- use_accelerate_endpoint(context)
50
- end
55
+ dualstack = !!context[:use_dualstack_endpoint]
56
+ use_accelerate_endpoint(context, dualstack)
51
57
  end
52
58
  @handler.call(context)
53
59
  end
54
60
 
55
61
  private
56
62
 
57
- def use_accelerate_endpoint(context)
63
+ def use_accelerate_endpoint(context, dualstack)
58
64
  bucket_name = context.params[:bucket]
59
65
  validate_bucket_name!(bucket_name)
60
66
  endpoint = URI.parse(context.http_request.endpoint.to_s)
61
67
  endpoint.scheme = 'https'
62
68
  endpoint.port = 443
63
- endpoint.host = "#{bucket_name}.s3-accelerate.amazonaws.com"
64
- context.http_request.endpoint = endpoint.to_s
65
- # s3 accelerate endpoint doesn't work with 'expect' header
66
- context.http_request.headers.delete('expect')
67
- end
68
-
69
- def use_combined_accelerate_dualstack_endpoint(context)
70
- bucket_name = context.params[:bucket]
71
- validate_bucket_name!(bucket_name)
72
- endpoint = URI.parse(context.http_request.endpoint.to_s)
73
- endpoint.scheme = 'https'
74
- endpoint.port = 443
75
- endpoint.host = "#{bucket_name}.s3-accelerate.dualstack.amazonaws.com"
69
+ endpoint.host = "#{bucket_name}.s3-accelerate"\
70
+ "#{'.dualstack' if dualstack}.amazonaws.com"
76
71
  context.http_request.endpoint = endpoint.to_s
77
72
  # s3 accelerate endpoint doesn't work with 'expect' header
78
73
  context.http_request.headers.delete('expect')
@@ -80,17 +75,11 @@ each bucket. [Go here for more information](http://docs.aws.amazon.com/AmazonS3
80
75
 
81
76
  def validate_bucket_name!(bucket_name)
82
77
  unless BucketDns.dns_compatible?(bucket_name, _ssl = true)
83
- msg = 'unable to use `accelerate: true` on buckets with '\
84
- 'non-DNS compatible names'
85
- raise ArgumentError, msg
86
- end
87
- if bucket_name.include?('.')
88
- msg = 'unable to use `accelerate: true` on buckets with dots'\
89
- "in their name: #{bucket_name.inspect}"
90
- raise ArgumentError, msg
78
+ raise ArgumentError,
79
+ 'Unable to use `use_accelerate_endpoint: true` on buckets '\
80
+ 'with non-DNS compatible names.'
91
81
  end
92
82
  end
93
-
94
83
  end
95
84
  end
96
85
  end