aws-sdk-s3 1.114.0 → 1.136.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +163 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-s3/bucket.rb +123 -61
  5. data/lib/aws-sdk-s3/bucket_acl.rb +9 -3
  6. data/lib/aws-sdk-s3/bucket_cors.rb +12 -4
  7. data/lib/aws-sdk-s3/bucket_lifecycle.rb +12 -4
  8. data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +12 -4
  9. data/lib/aws-sdk-s3/bucket_logging.rb +9 -3
  10. data/lib/aws-sdk-s3/bucket_notification.rb +9 -3
  11. data/lib/aws-sdk-s3/bucket_policy.rb +12 -4
  12. data/lib/aws-sdk-s3/bucket_request_payment.rb +9 -3
  13. data/lib/aws-sdk-s3/bucket_tagging.rb +12 -4
  14. data/lib/aws-sdk-s3/bucket_versioning.rb +15 -5
  15. data/lib/aws-sdk-s3/bucket_website.rb +12 -4
  16. data/lib/aws-sdk-s3/client.rb +2084 -1724
  17. data/lib/aws-sdk-s3/client_api.rb +213 -189
  18. data/lib/aws-sdk-s3/customizations/bucket.rb +23 -47
  19. data/lib/aws-sdk-s3/customizations/errors.rb +27 -0
  20. data/lib/aws-sdk-s3/customizations/object.rb +95 -19
  21. data/lib/aws-sdk-s3/customizations/types/permanent_redirect.rb +26 -0
  22. data/lib/aws-sdk-s3/customizations.rb +2 -0
  23. data/lib/aws-sdk-s3/encryption/client.rb +6 -2
  24. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +13 -9
  25. data/lib/aws-sdk-s3/encryptionV2/client.rb +6 -2
  26. data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +1 -0
  27. data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +10 -6
  28. data/lib/aws-sdk-s3/endpoint_parameters.rb +146 -0
  29. data/lib/aws-sdk-s3/endpoint_provider.rb +509 -0
  30. data/lib/aws-sdk-s3/endpoints.rb +2150 -0
  31. data/lib/aws-sdk-s3/file_downloader.rb +170 -44
  32. data/lib/aws-sdk-s3/file_uploader.rb +8 -6
  33. data/lib/aws-sdk-s3/multipart_stream_uploader.rb +41 -13
  34. data/lib/aws-sdk-s3/multipart_upload.rb +27 -13
  35. data/lib/aws-sdk-s3/multipart_upload_part.rb +20 -10
  36. data/lib/aws-sdk-s3/object.rb +156 -110
  37. data/lib/aws-sdk-s3/object_acl.rb +14 -6
  38. data/lib/aws-sdk-s3/object_copier.rb +7 -5
  39. data/lib/aws-sdk-s3/object_multipart_copier.rb +41 -19
  40. data/lib/aws-sdk-s3/object_summary.rb +149 -94
  41. data/lib/aws-sdk-s3/object_version.rb +55 -21
  42. data/lib/aws-sdk-s3/plugins/accelerate.rb +3 -50
  43. data/lib/aws-sdk-s3/plugins/arn.rb +0 -184
  44. data/lib/aws-sdk-s3/plugins/bucket_dns.rb +3 -39
  45. data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +1 -6
  46. data/lib/aws-sdk-s3/plugins/dualstack.rb +1 -49
  47. data/lib/aws-sdk-s3/plugins/endpoints.rb +262 -0
  48. data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +2 -1
  49. data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +0 -29
  50. data/lib/aws-sdk-s3/plugins/s3_signer.rb +32 -126
  51. data/lib/aws-sdk-s3/presigned_post.rb +61 -59
  52. data/lib/aws-sdk-s3/presigner.rb +24 -35
  53. data/lib/aws-sdk-s3/resource.rb +7 -3
  54. data/lib/aws-sdk-s3/types.rb +858 -4125
  55. data/lib/aws-sdk-s3.rb +5 -1
  56. metadata +12 -11
  57. data/lib/aws-sdk-s3/arn/access_point_arn.rb +0 -69
  58. data/lib/aws-sdk-s3/arn/multi_region_access_point_arn.rb +0 -68
  59. data/lib/aws-sdk-s3/arn/object_lambda_arn.rb +0 -69
  60. data/lib/aws-sdk-s3/arn/outpost_access_point_arn.rb +0 -74
  61. data/lib/aws-sdk-s3/plugins/object_lambda_endpoint.rb +0 -25
@@ -28,11 +28,13 @@ module Aws
28
28
  options[:bucket] = target_bucket
29
29
  options[:key] = target_key
30
30
  options[:copy_source] = copy_source(source)
31
- if options.delete(:multipart_copy)
32
- apply_source_client(source, options)
33
- ObjectMultipartCopier.new(@options).copy(options)
34
- else
35
- @object.client.copy_object(options)
31
+ Aws::Plugins::UserAgent.feature('s3-transfer') do
32
+ if options.delete(:multipart_copy)
33
+ apply_source_client(source, options)
34
+ ObjectMultipartCopier.new(@options).copy(options)
35
+ else
36
+ @object.client.copy_object(options)
37
+ end
36
38
  end
37
39
  end
38
40
 
@@ -15,12 +15,18 @@ module Aws
15
15
  MAX_PARTS = 10_000
16
16
 
17
17
  # @option options [Client] :client
18
- # @option [Integer] :min_part_size (52428800) Size of copied parts.
19
- # Defaults to 50MB.
20
- # will be constructed from the given `options' hash.
21
- # @option [Integer] :thread_count (10) Number of concurrent threads to
22
- # use for copying parts.
18
+ # @option options [Integer] :min_part_size (52428800)
19
+ # Size of copied parts. Defaults to 50MB.
20
+ # @option options [Integer] :thread_count (10) Number of concurrent
21
+ # threads to use for copying parts.
22
+ # @option options [Boolean] :use_source_parts (false) Use part sizes
23
+ # defined on the source object if any exist. If copying or moving an
24
+ # object that is already multipart, this does not re-part the object,
25
+ # instead re-using the part definitions on the original. That means
26
+ # the etag and any checksums will not change. This is especially
27
+ # useful if the source object has parts with varied sizes.
23
28
  def initialize(options = {})
29
+ @use_source_parts = options.delete(:use_source_parts) || false
24
30
  @thread_count = options.delete(:thread_count) || 10
25
31
  @min_part_size = options.delete(:min_part_size) || (FIVE_MB * 10)
26
32
  @client = options[:client] || Client.new
@@ -31,8 +37,9 @@ module Aws
31
37
 
32
38
  # @option (see S3::Client#copy_object)
33
39
  def copy(options = {})
34
- size = source_size(options)
35
- options[:upload_id] = initiate_upload(options)
40
+ metadata = source_metadata(options)
41
+ size = metadata[:content_length]
42
+ options[:upload_id] = initiate_upload(metadata.merge(options))
36
43
  begin
37
44
  parts = copy_parts(size, default_part_size(size), options)
38
45
  complete_upload(parts, options)
@@ -74,10 +81,9 @@ module Aws
74
81
  end
75
82
 
76
83
  def copy_part(part)
77
- {
78
- etag: @client.upload_part_copy(part).copy_part_result.etag,
79
- part_number: part[:part_number],
80
- }
84
+ @client.upload_part_copy(part).copy_part_result.to_h.merge({
85
+ part_number: part[:part_number]
86
+ }).tap { |result| result.delete(:last_modified) }
81
87
  end
82
88
 
83
89
  def complete_upload(parts, options)
@@ -100,26 +106,41 @@ module Aws
100
106
  parts = []
101
107
  options = options_for(:upload_part_copy, options)
102
108
  while offset < size
109
+ part_size = calculate_part_size(part_number, default_part_size, options)
103
110
  parts << options.merge({
104
111
  part_number: part_number,
105
- copy_source_range: byte_range(offset, default_part_size, size),
112
+ copy_source_range: byte_range(offset, part_size, size),
106
113
  })
107
114
  part_number += 1
108
- offset += default_part_size
115
+ offset += part_size
109
116
  end
110
117
  parts
111
118
  end
112
119
 
113
- def byte_range(offset, default_part_size, size)
114
- if offset + default_part_size < size
115
- "bytes=#{offset}-#{offset + default_part_size - 1}"
120
+ def byte_range(offset, part_size, size)
121
+ if offset + part_size < size
122
+ "bytes=#{offset}-#{offset + part_size - 1}"
116
123
  else
117
124
  "bytes=#{offset}-#{size - 1}"
118
125
  end
119
126
  end
120
127
 
121
- def source_size(options)
122
- return options.delete(:content_length) if options[:content_length]
128
+ def calculate_part_size(part_number, default_part_size, options)
129
+ if @use_source_parts && source_has_parts(options)
130
+ source_metadata(options.merge({ part_number: part_number }))[:content_length]
131
+ else
132
+ default_part_size
133
+ end
134
+ end
135
+
136
+ def source_has_parts(options)
137
+ @source_has_parts ||= source_metadata(options.merge({ part_number: 1 }))[:parts_count]
138
+ end
139
+
140
+ def source_metadata(options)
141
+ if options[:content_length]
142
+ return { content_length: options.delete(:content_length) }
143
+ end
123
144
 
124
145
  client = options[:copy_source_client] || @client
125
146
 
@@ -132,7 +153,8 @@ module Aws
132
153
  key = CGI.unescape(key)
133
154
  opts = { bucket: bucket, key: key }
134
155
  opts[:version_id] = version_id if version_id
135
- client.head_object(opts).content_length
156
+ opts[:part_number] = options[:part_number] if options[:part_number]
157
+ client.head_object(opts).to_h
136
158
  end
137
159
 
138
160
  def default_part_size(source_size)