aws-sdk-s3 1.72.0 → 1.77.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 (40) 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 +64 -29
  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/io_decrypter.rb +7 -6
  12. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +32 -3
  13. data/lib/aws-sdk-s3/encryption/utils.rb +23 -0
  14. data/lib/aws-sdk-s3/encryptionV2/client.rb +201 -23
  15. data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +40 -12
  16. data/lib/aws-sdk-s3/encryptionV2/default_cipher_provider.rb +77 -10
  17. data/lib/aws-sdk-s3/encryptionV2/default_key_provider.rb +2 -0
  18. data/lib/aws-sdk-s3/encryptionV2/encrypt_handler.rb +7 -4
  19. data/lib/aws-sdk-s3/encryptionV2/errors.rb +24 -0
  20. data/lib/aws-sdk-s3/encryptionV2/io_auth_decrypter.rb +2 -0
  21. data/lib/aws-sdk-s3/encryptionV2/io_decrypter.rb +2 -0
  22. data/lib/aws-sdk-s3/encryptionV2/io_encrypter.rb +2 -0
  23. data/lib/aws-sdk-s3/encryptionV2/key_provider.rb +2 -0
  24. data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +90 -20
  25. data/lib/aws-sdk-s3/encryptionV2/materials.rb +2 -0
  26. data/lib/aws-sdk-s3/encryptionV2/utils.rb +2 -15
  27. data/lib/aws-sdk-s3/encryption_v2.rb +4 -1
  28. data/lib/aws-sdk-s3/file_uploader.rb +11 -0
  29. data/lib/aws-sdk-s3/multipart_file_uploader.rb +37 -2
  30. data/lib/aws-sdk-s3/multipart_upload_part.rb +5 -5
  31. data/lib/aws-sdk-s3/object.rb +10 -9
  32. data/lib/aws-sdk-s3/object_summary.rb +23 -7
  33. data/lib/aws-sdk-s3/object_version.rb +2 -2
  34. data/lib/aws-sdk-s3/plugins/accelerate.rb +27 -38
  35. data/lib/aws-sdk-s3/plugins/dualstack.rb +3 -1
  36. data/lib/aws-sdk-s3/plugins/sse_cpk.rb +1 -1
  37. data/lib/aws-sdk-s3/presigned_post.rb +61 -28
  38. data/lib/aws-sdk-s3/presigner.rb +2 -2
  39. data/lib/aws-sdk-s3/types.rb +63 -26
  40. metadata +4 -4
@@ -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
@@ -22,7 +22,9 @@ for all operations.
22
22
  # @api private
23
23
  class OptionHandler < Seahorse::Client::Handler
24
24
  def call(context)
25
- dualstack = context.params.delete(:use_dualstack_endpoint)
25
+ if context.params.is_a?(Hash)
26
+ dualstack = context.params.delete(:use_dualstack_endpoint)
27
+ end
26
28
  dualstack = context.config.use_dualstack_endpoint if dualstack.nil?
27
29
  context[:use_dualstack_endpoint] = dualstack
28
30
  @handler.call(context)
@@ -20,7 +20,7 @@ This should only be disabled for local testing.
20
20
  class Handler < Seahorse::Client::Handler
21
21
 
22
22
  def call(context)
23
- compute_key_md5(context)
23
+ compute_key_md5(context) if context.params.is_a?(Hash)
24
24
  @handler.call(context)
25
25
  end
26
26
 
@@ -185,35 +185,58 @@ module Aws
185
185
  # the post will expire. Defaults to one hour from creation of the
186
186
  # presigned post. May not exceed one week from creation time.
187
187
  # @option options [String] :key See {PresignedPost#key}.
188
- # @option options [String] :key_starts_with See {PresignedPost#key_starts_with}.
188
+ # @option options [String] :key_starts_with
189
+ # See {PresignedPost#key_starts_with}.
189
190
  # @option options [String] :acl See {PresignedPost#acl}.
190
- # @option options [String] :acl_starts_with See {PresignedPost#acl_starts_with}.
191
- # @option options [String] :cache_control See {PresignedPost#cache_control}.
192
- # @option options [String] :cache_control_starts_with See {PresignedPost#cache_control_starts_with}.
191
+ # @option options [String] :acl_starts_with
192
+ # See {PresignedPost#acl_starts_with}.
193
+ # @option options [String] :cache_control
194
+ # See {PresignedPost#cache_control}.
195
+ # @option options [String] :cache_control_starts_with
196
+ # See {PresignedPost#cache_control_starts_with}.
193
197
  # @option options [String] :content_type See {PresignedPost#content_type}.
194
- # @option options [String] :content_type_starts_with See {PresignedPost#content_type_starts_with}.
195
- # @option options [String] :content_disposition See {PresignedPost#content_disposition}.
196
- # @option options [String] :content_disposition_starts_with See {PresignedPost#content_disposition_starts_with}.
197
- # @option options [String] :content_encoding See {PresignedPost#content_encoding}.
198
- # @option options [String] :content_encoding_starts_with See {PresignedPost#content_encoding_starts_with}.
198
+ # @option options [String] :content_type_starts_with
199
+ # See {PresignedPost#content_type_starts_with}.
200
+ # @option options [String] :content_disposition
201
+ # See {PresignedPost#content_disposition}.
202
+ # @option options [String] :content_disposition_starts_with
203
+ # See {PresignedPost#content_disposition_starts_with}.
204
+ # @option options [String] :content_encoding
205
+ # See {PresignedPost#content_encoding}.
206
+ # @option options [String] :content_encoding_starts_with
207
+ # See {PresignedPost#content_encoding_starts_with}.
199
208
  # @option options [String] :expires See {PresignedPost#expires}.
200
- # @option options [String] :expires_starts_with See {PresignedPost#expires_starts_with}.
201
- # @option options [Range<Integer>] :content_length_range See {PresignedPost#content_length_range}.
202
- # @option options [String] :success_action_redirect See {PresignedPost#success_action_redirect}.
203
- # @option options [String] :success_action_redirect_starts_with See {PresignedPost#success_action_redirect_starts_with}.
204
- # @option options [String] :success_action_status See {PresignedPost#success_action_status}.
205
- # @option options [String] :storage_class See {PresignedPost#storage_class}.
206
- # @option options [String] :website_redirect_location See {PresignedPost#website_redirect_location}.
207
- # @option options [Hash<String,String>] :metadata See {PresignedPost#metadata}.
208
- # @option options [Hash<String,String>] :metadata_starts_with See {PresignedPost#metadata_starts_with}.
209
- # @option options [String] :server_side_encryption See {PresignedPost#server_side_encryption}.
210
- # @option options [String] :server_side_encryption_aws_kms_key_id See {PresignedPost#server_side_encryption_aws_kms_key_id}.
211
- # @option options [String] :server_side_encryption_customer_algorithm See {PresignedPost#server_side_encryption_customer_algorithm}.
212
- # @option options [String] :server_side_encryption_customer_key See {PresignedPost#server_side_encryption_customer_key}.
209
+ # @option options [String] :expires_starts_with
210
+ # See {PresignedPost#expires_starts_with}.
211
+ # @option options [Range<Integer>] :content_length_range
212
+ # See {PresignedPost#content_length_range}.
213
+ # @option options [String] :success_action_redirect
214
+ # See {PresignedPost#success_action_redirect}.
215
+ # @option options [String] :success_action_redirect_starts_with
216
+ # See {PresignedPost#success_action_redirect_starts_with}.
217
+ # @option options [String] :success_action_status
218
+ # See {PresignedPost#success_action_status}.
219
+ # @option options [String] :storage_class
220
+ # See {PresignedPost#storage_class}.
221
+ # @option options [String] :website_redirect_location
222
+ # See {PresignedPost#website_redirect_location}.
223
+ # @option options [Hash<String,String>] :metadata
224
+ # See {PresignedPost#metadata}.
225
+ # @option options [Hash<String,String>] :metadata_starts_with
226
+ # See {PresignedPost#metadata_starts_with}.
227
+ # @option options [String] :server_side_encryption
228
+ # See {PresignedPost#server_side_encryption}.
229
+ # @option options [String] :server_side_encryption_aws_kms_key_id
230
+ # See {PresignedPost#server_side_encryption_aws_kms_key_id}.
231
+ # @option options [String] :server_side_encryption_customer_algorithm
232
+ # See {PresignedPost#server_side_encryption_customer_algorithm}.
233
+ # @option options [String] :server_side_encryption_customer_key
234
+ # See {PresignedPost#server_side_encryption_customer_key}.
213
235
  def initialize(credentials, bucket_region, bucket_name, options = {})
214
236
  @credentials = credentials.credentials
215
237
  @bucket_region = bucket_region
216
238
  @bucket_name = bucket_name
239
+ @accelerate = !!options.delete(:use_accelerate_endpoint)
217
240
  @url = options.delete(:url) || bucket_url
218
241
  @fields = {}
219
242
  @key_set = false
@@ -272,7 +295,7 @@ module Aws
272
295
 
273
296
  # @!group Fields
274
297
 
275
- # The key to use for the uploaded object. Use can use `${filename}`
298
+ # The key to use for the uploaded object. You can use `${filename}`
276
299
  # as a variable in the key. This will be replaced with the name
277
300
  # of the file as provided by the user.
278
301
  #
@@ -507,7 +530,10 @@ module Aws
507
530
  # (KMS) master encryption key to use for the object.
508
531
  # @param [String] value
509
532
  # @return [self]
510
- define_field(:server_side_encryption_aws_kms_key_id, 'x-amz-server-side-encryption-aws-kms-key-id')
533
+ define_field(
534
+ :server_side_encryption_aws_kms_key_id,
535
+ 'x-amz-server-side-encryption-aws-kms-key-id'
536
+ )
511
537
 
512
538
  # @!endgroup
513
539
 
@@ -520,7 +546,10 @@ module Aws
520
546
  # @param [String] value
521
547
  # @see #server_side_encryption_customer_key
522
548
  # @return [self]
523
- define_field(:server_side_encryption_customer_algorithm, 'x-amz-server-side-encryption-customer-algorithm')
549
+ define_field(
550
+ :server_side_encryption_customer_algorithm,
551
+ 'x-amz-server-side-encryption-customer-algorithm'
552
+ )
524
553
 
525
554
  # Specifies the customer-provided encryption key for Amazon S3 to use
526
555
  # in encrypting data. This value is used to store the object and then
@@ -582,10 +611,14 @@ module Aws
582
611
  def bucket_url
583
612
  url = Aws::Partitions::EndpointProvider.resolve(@bucket_region, 's3')
584
613
  url = URI.parse(url)
585
- if Plugins::BucketDns.dns_compatible?(@bucket_name, true)
586
- url.host = @bucket_name + '.' + url.host
614
+ if Plugins::BucketDns.dns_compatible?(@bucket_name, _ssl = true)
615
+ if @accelerate
616
+ url.host = "#{@bucket_name}.s3-accelerate.amazonaws.com"
617
+ else
618
+ url.host = "#{@bucket_name}.#{url.host}"
619
+ end
587
620
  else
588
- url.path = '/' + @bucket_name
621
+ url.path = "/#{@bucket_name}"
589
622
  end
590
623
  if @bucket_region == 'us-east-1'
591
624
  # keep legacy behavior by default