aws-sdk-s3 1.113.0 → 1.129.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +131 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-s3/bucket.rb +108 -55
- data/lib/aws-sdk-s3/bucket_acl.rb +9 -3
- data/lib/aws-sdk-s3/bucket_cors.rb +12 -4
- data/lib/aws-sdk-s3/bucket_lifecycle.rb +12 -4
- data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +12 -4
- data/lib/aws-sdk-s3/bucket_logging.rb +9 -3
- data/lib/aws-sdk-s3/bucket_notification.rb +9 -3
- data/lib/aws-sdk-s3/bucket_policy.rb +12 -4
- data/lib/aws-sdk-s3/bucket_request_payment.rb +9 -3
- data/lib/aws-sdk-s3/bucket_tagging.rb +12 -4
- data/lib/aws-sdk-s3/bucket_versioning.rb +15 -5
- data/lib/aws-sdk-s3/bucket_website.rb +12 -4
- data/lib/aws-sdk-s3/client.rb +1869 -1550
- data/lib/aws-sdk-s3/client_api.rb +213 -189
- data/lib/aws-sdk-s3/customizations/bucket.rb +23 -47
- data/lib/aws-sdk-s3/customizations/errors.rb +27 -0
- data/lib/aws-sdk-s3/customizations/object.rb +32 -19
- data/lib/aws-sdk-s3/customizations/types/permanent_redirect.rb +26 -0
- data/lib/aws-sdk-s3/customizations.rb +2 -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 +142 -0
- data/lib/aws-sdk-s3/endpoint_provider.rb +733 -0
- data/lib/aws-sdk-s3/endpoints.rb +2150 -0
- data/lib/aws-sdk-s3/file_downloader.rb +28 -24
- data/lib/aws-sdk-s3/file_uploader.rb +8 -6
- data/lib/aws-sdk-s3/multipart_stream_uploader.rb +41 -13
- data/lib/aws-sdk-s3/multipart_upload.rb +12 -4
- data/lib/aws-sdk-s3/multipart_upload_part.rb +10 -4
- data/lib/aws-sdk-s3/object.rb +105 -77
- data/lib/aws-sdk-s3/object_acl.rb +9 -3
- data/lib/aws-sdk-s3/object_copier.rb +7 -5
- data/lib/aws-sdk-s3/object_multipart_copier.rb +11 -5
- data/lib/aws-sdk-s3/object_summary.rb +106 -65
- data/lib/aws-sdk-s3/object_version.rb +35 -9
- data/lib/aws-sdk-s3/plugins/accelerate.rb +3 -50
- 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 +262 -0
- data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +2 -1
- data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +0 -29
- data/lib/aws-sdk-s3/plugins/s3_signer.rb +35 -124
- data/lib/aws-sdk-s3/plugins/streaming_retry.rb +23 -2
- data/lib/aws-sdk-s3/presigned_post.rb +61 -59
- data/lib/aws-sdk-s3/presigner.rb +24 -35
- data/lib/aws-sdk-s3/resource.rb +7 -3
- data/lib/aws-sdk-s3/types.rb +714 -4040
- data/lib/aws-sdk-s3.rb +5 -1
- metadata +12 -11
- 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
@@ -32,21 +32,23 @@ module Aws
|
|
32
32
|
}
|
33
33
|
@params[:version_id] = options[:version_id] if options[:version_id]
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
35
|
+
Aws::Plugins::UserAgent.feature('s3-transfer') do
|
36
|
+
case @mode
|
37
|
+
when 'auto' then multipart_download
|
38
|
+
when 'single_request' then single_request
|
39
|
+
when 'get_range'
|
40
|
+
if @chunk_size
|
41
|
+
resp = @client.head_object(@params)
|
42
|
+
multithreaded_get_by_ranges(construct_chunks(resp.content_length))
|
43
|
+
else
|
44
|
+
msg = 'In :get_range mode, :chunk_size must be provided'
|
45
|
+
raise ArgumentError, msg
|
46
|
+
end
|
42
47
|
else
|
43
|
-
msg =
|
48
|
+
msg = "Invalid mode #{@mode} provided, "\
|
49
|
+
'mode should be :single_request, :get_range or :auto'
|
44
50
|
raise ArgumentError, msg
|
45
51
|
end
|
46
|
-
else
|
47
|
-
msg = "Invalid mode #{@mode} provided, "\
|
48
|
-
'mode should be :single_request, :get_range or :auto'
|
49
|
-
raise ArgumentError, msg
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
@@ -56,15 +58,19 @@ module Aws
|
|
56
58
|
resp = @client.head_object(@params.merge(part_number: 1))
|
57
59
|
count = resp.parts_count
|
58
60
|
if count.nil? || count <= 1
|
59
|
-
resp.content_length
|
60
|
-
single_request
|
61
|
+
if resp.content_length <= MIN_CHUNK_SIZE
|
62
|
+
single_request
|
63
|
+
else
|
61
64
|
multithreaded_get_by_ranges(construct_chunks(resp.content_length))
|
65
|
+
end
|
62
66
|
else
|
63
67
|
# partNumber is an option
|
64
68
|
resp = @client.head_object(@params)
|
65
|
-
resp.content_length
|
66
|
-
single_request
|
69
|
+
if resp.content_length <= MIN_CHUNK_SIZE
|
70
|
+
single_request
|
71
|
+
else
|
67
72
|
compute_mode(resp.content_length, count)
|
73
|
+
end
|
68
74
|
end
|
69
75
|
end
|
70
76
|
|
@@ -82,10 +88,11 @@ module Aws
|
|
82
88
|
offset = 0
|
83
89
|
default_chunk_size = compute_chunk(file_size)
|
84
90
|
chunks = []
|
85
|
-
while offset
|
91
|
+
while offset < file_size
|
86
92
|
progress = offset + default_chunk_size
|
87
|
-
|
88
|
-
|
93
|
+
progress = file_size if progress > file_size
|
94
|
+
chunks << "bytes=#{offset}-#{progress - 1}"
|
95
|
+
offset = progress
|
89
96
|
end
|
90
97
|
chunks
|
91
98
|
end
|
@@ -94,12 +101,9 @@ module Aws
|
|
94
101
|
if @chunk_size && @chunk_size > file_size
|
95
102
|
raise ArgumentError, ":chunk_size shouldn't exceed total file size."
|
96
103
|
else
|
97
|
-
|
98
|
-
(file_size.to_f / MAX_PARTS).ceil,
|
99
|
-
MIN_CHUNK_SIZE
|
104
|
+
@chunk_size || [
|
105
|
+
(file_size.to_f / MAX_PARTS).ceil, MIN_CHUNK_SIZE
|
100
106
|
].max.to_i
|
101
|
-
chunk_size -= 1 if file_size % chunk_size == 1
|
102
|
-
chunk_size
|
103
107
|
end
|
104
108
|
end
|
105
109
|
|
@@ -37,12 +37,14 @@ module Aws
|
|
37
37
|
# objects smaller than the multipart threshold.
|
38
38
|
# @return [void]
|
39
39
|
def upload(source, options = {})
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
Aws::Plugins::UserAgent.feature('s3-transfer') do
|
41
|
+
if File.size(source) >= multipart_threshold
|
42
|
+
MultipartFileUploader.new(@options).upload(source, options)
|
43
|
+
else
|
44
|
+
# remove multipart parameters not supported by put_object
|
45
|
+
options.delete(:thread_count)
|
46
|
+
put_object(source, options)
|
47
|
+
end
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
@@ -26,6 +26,10 @@ module Aws
|
|
26
26
|
UPLOAD_PART_OPTIONS =
|
27
27
|
Set.new(Client.api.operation(:upload_part).input.shape.member_names)
|
28
28
|
|
29
|
+
# @api private
|
30
|
+
COMPLETE_UPLOAD_OPTIONS =
|
31
|
+
Set.new(Client.api.operation(:complete_multipart_upload).input.shape.member_names)
|
32
|
+
|
29
33
|
# @option options [Client] :client
|
30
34
|
def initialize(options = {})
|
31
35
|
@client = options[:client] || Client.new
|
@@ -39,11 +43,13 @@ module Aws
|
|
39
43
|
|
40
44
|
# @option options [required,String] :bucket
|
41
45
|
# @option options [required,String] :key
|
42
|
-
# @return [
|
46
|
+
# @return [Seahorse::Client::Response] - the CompleteMultipartUploadResponse
|
43
47
|
def upload(options = {}, &block)
|
44
|
-
|
45
|
-
|
46
|
-
|
48
|
+
Aws::Plugins::UserAgent.feature('s3-transfer') do
|
49
|
+
upload_id = initiate_upload(options)
|
50
|
+
parts = upload_parts(upload_id, options, &block)
|
51
|
+
complete_upload(upload_id, parts, options)
|
52
|
+
end
|
47
53
|
end
|
48
54
|
|
49
55
|
private
|
@@ -54,17 +60,22 @@ module Aws
|
|
54
60
|
|
55
61
|
def complete_upload(upload_id, parts, options)
|
56
62
|
@client.complete_multipart_upload(
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
63
|
+
**complete_opts(options).merge(
|
64
|
+
upload_id: upload_id,
|
65
|
+
multipart_upload: { parts: parts }
|
66
|
+
)
|
67
|
+
)
|
61
68
|
end
|
62
69
|
|
63
70
|
def upload_parts(upload_id, options, &block)
|
64
71
|
completed = Queue.new
|
72
|
+
thread_errors = []
|
65
73
|
errors = begin
|
66
74
|
IO.pipe do |read_pipe, write_pipe|
|
67
|
-
threads = upload_in_threads(
|
75
|
+
threads = upload_in_threads(
|
76
|
+
read_pipe, completed,
|
77
|
+
upload_part_opts(options).merge(upload_id: upload_id),
|
78
|
+
thread_errors)
|
68
79
|
begin
|
69
80
|
block.call(write_pipe)
|
70
81
|
ensure
|
@@ -74,7 +85,7 @@ module Aws
|
|
74
85
|
threads.map(&:value).compact
|
75
86
|
end
|
76
87
|
rescue => e
|
77
|
-
[e]
|
88
|
+
thread_errors + [e]
|
78
89
|
end
|
79
90
|
|
80
91
|
if errors.empty?
|
@@ -113,6 +124,13 @@ module Aws
|
|
113
124
|
end
|
114
125
|
end
|
115
126
|
|
127
|
+
def complete_opts(options)
|
128
|
+
COMPLETE_UPLOAD_OPTIONS.inject({}) do |hash, key|
|
129
|
+
hash[key] = options[key] if options.key?(key)
|
130
|
+
hash
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
116
134
|
def read_to_part_body(read_pipe)
|
117
135
|
return if read_pipe.closed?
|
118
136
|
temp_io = @tempfile ? Tempfile.new(TEMPFILE_PREIX) : StringIO.new(String.new)
|
@@ -130,7 +148,7 @@ module Aws
|
|
130
148
|
end
|
131
149
|
end
|
132
150
|
|
133
|
-
def upload_in_threads(read_pipe, completed, options)
|
151
|
+
def upload_in_threads(read_pipe, completed, options, thread_errors)
|
134
152
|
mutex = Mutex.new
|
135
153
|
part_number = 0
|
136
154
|
@thread_count.times.map do
|
@@ -147,7 +165,14 @@ module Aws
|
|
147
165
|
part_number: thread_part_number,
|
148
166
|
)
|
149
167
|
resp = @client.upload_part(part)
|
150
|
-
|
168
|
+
completed_part = {etag: resp.etag, part_number: part[:part_number]}
|
169
|
+
|
170
|
+
# get the requested checksum from the response
|
171
|
+
if part[:checksum_algorithm]
|
172
|
+
k = "checksum_#{part[:checksum_algorithm].downcase}".to_sym
|
173
|
+
completed_part[k] = resp[k]
|
174
|
+
end
|
175
|
+
completed.push(completed_part)
|
151
176
|
ensure
|
152
177
|
if Tempfile === body
|
153
178
|
body.close
|
@@ -160,7 +185,10 @@ module Aws
|
|
160
185
|
nil
|
161
186
|
rescue => error
|
162
187
|
# keep other threads from uploading other parts
|
163
|
-
mutex.synchronize
|
188
|
+
mutex.synchronize do
|
189
|
+
thread_errors.push(error)
|
190
|
+
read_pipe.close_read unless read_pipe.closed?
|
191
|
+
end
|
164
192
|
error
|
165
193
|
end
|
166
194
|
end
|
@@ -217,7 +217,9 @@ module Aws::S3
|
|
217
217
|
:retry
|
218
218
|
end
|
219
219
|
end
|
220
|
-
Aws::
|
220
|
+
Aws::Plugins::UserAgent.feature('resource') do
|
221
|
+
Aws::Waiters::Waiter.new(options).wait({})
|
222
|
+
end
|
221
223
|
end
|
222
224
|
|
223
225
|
# @!group Actions
|
@@ -250,7 +252,9 @@ module Aws::S3
|
|
250
252
|
key: @object_key,
|
251
253
|
upload_id: @id
|
252
254
|
)
|
253
|
-
resp =
|
255
|
+
resp = Aws::Plugins::UserAgent.feature('resource') do
|
256
|
+
@client.abort_multipart_upload(options)
|
257
|
+
end
|
254
258
|
resp.data
|
255
259
|
end
|
256
260
|
|
@@ -370,7 +374,9 @@ module Aws::S3
|
|
370
374
|
key: @object_key,
|
371
375
|
upload_id: @id
|
372
376
|
)
|
373
|
-
|
377
|
+
Aws::Plugins::UserAgent.feature('resource') do
|
378
|
+
@client.complete_multipart_upload(options)
|
379
|
+
end
|
374
380
|
Object.new(
|
375
381
|
bucket_name: @bucket_name,
|
376
382
|
key: @object_key,
|
@@ -460,7 +466,9 @@ module Aws::S3
|
|
460
466
|
key: @object_key,
|
461
467
|
upload_id: @id
|
462
468
|
)
|
463
|
-
resp =
|
469
|
+
resp = Aws::Plugins::UserAgent.feature('resource') do
|
470
|
+
@client.list_parts(options)
|
471
|
+
end
|
464
472
|
resp.each_page do |page|
|
465
473
|
batch = []
|
466
474
|
page.data.parts.each do |p|
|
@@ -256,7 +256,9 @@ module Aws::S3
|
|
256
256
|
:retry
|
257
257
|
end
|
258
258
|
end
|
259
|
-
Aws::
|
259
|
+
Aws::Plugins::UserAgent.feature('resource') do
|
260
|
+
Aws::Waiters::Waiter.new(options).wait({})
|
261
|
+
end
|
260
262
|
end
|
261
263
|
|
262
264
|
# @!group Actions
|
@@ -284,7 +286,7 @@ module Aws::S3
|
|
284
286
|
# @option options [required, String] :copy_source
|
285
287
|
# Specifies the source object for the copy operation. You specify the
|
286
288
|
# value in one of two formats, depending on whether you want to access
|
287
|
-
# the source object through an [access point][1]
|
289
|
+
# the source object through an [access point][1]:
|
288
290
|
#
|
289
291
|
# * For objects not accessed through an access point, specify the name
|
290
292
|
# of the source bucket and key of the source object, separated by a
|
@@ -395,7 +397,9 @@ module Aws::S3
|
|
395
397
|
upload_id: @multipart_upload_id,
|
396
398
|
part_number: @part_number
|
397
399
|
)
|
398
|
-
resp =
|
400
|
+
resp = Aws::Plugins::UserAgent.feature('resource') do
|
401
|
+
@client.upload_part_copy(options)
|
402
|
+
end
|
399
403
|
resp.data
|
400
404
|
end
|
401
405
|
|
@@ -521,7 +525,9 @@ module Aws::S3
|
|
521
525
|
upload_id: @multipart_upload_id,
|
522
526
|
part_number: @part_number
|
523
527
|
)
|
524
|
-
resp =
|
528
|
+
resp = Aws::Plugins::UserAgent.feature('resource') do
|
529
|
+
@client.upload_part(options)
|
530
|
+
end
|
525
531
|
resp.data
|
526
532
|
end
|
527
533
|
|