aws-sdk-s3 1.128.0 → 1.131.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 +18 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-s3/bucket.rb +1 -1
- data/lib/aws-sdk-s3/client.rb +88 -82
- data/lib/aws-sdk-s3/customizations/errors.rb +1 -1
- data/lib/aws-sdk-s3/customizations/object.rb +8 -0
- data/lib/aws-sdk-s3/endpoint_parameters.rb +4 -0
- data/lib/aws-sdk-s3/endpoint_provider.rb +22 -246
- data/lib/aws-sdk-s3/object_multipart_copier.rb +33 -17
- data/lib/aws-sdk-s3/presigned_post.rb +52 -43
- data/lib/aws-sdk-s3/resource.rb +1 -1
- data/lib/aws-sdk-s3.rb +1 -1
- metadata +2 -2
@@ -15,18 +15,21 @@ module Aws
|
|
15
15
|
MAX_PARTS = 10_000
|
16
16
|
|
17
17
|
# @option options [Client] :client
|
18
|
-
# @option [Integer] :min_part_size (52428800)
|
19
|
-
# Defaults to 50MB.
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
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
|
27
|
-
if options[:checksum_algorithm]
|
28
|
-
raise ArgumentError, 'Multipart Copy does not support setting :checksum_algorithm'
|
29
|
-
end
|
30
33
|
end
|
31
34
|
|
32
35
|
# @return [Client]
|
@@ -78,10 +81,9 @@ module Aws
|
|
78
81
|
end
|
79
82
|
|
80
83
|
def copy_part(part)
|
81
|
-
{
|
82
|
-
|
83
|
-
|
84
|
-
}
|
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) }
|
85
87
|
end
|
86
88
|
|
87
89
|
def complete_upload(parts, options)
|
@@ -104,24 +106,37 @@ module Aws
|
|
104
106
|
parts = []
|
105
107
|
options = options_for(:upload_part_copy, options)
|
106
108
|
while offset < size
|
109
|
+
part_size = calculate_part_size(part_number, default_part_size, options)
|
107
110
|
parts << options.merge({
|
108
111
|
part_number: part_number,
|
109
|
-
copy_source_range: byte_range(offset,
|
112
|
+
copy_source_range: byte_range(offset, part_size, size),
|
110
113
|
})
|
111
114
|
part_number += 1
|
112
|
-
offset +=
|
115
|
+
offset += part_size
|
113
116
|
end
|
114
117
|
parts
|
115
118
|
end
|
116
119
|
|
117
|
-
def byte_range(offset,
|
118
|
-
if offset +
|
119
|
-
"bytes=#{offset}-#{offset +
|
120
|
+
def byte_range(offset, part_size, size)
|
121
|
+
if offset + part_size < size
|
122
|
+
"bytes=#{offset}-#{offset + part_size - 1}"
|
120
123
|
else
|
121
124
|
"bytes=#{offset}-#{size - 1}"
|
122
125
|
end
|
123
126
|
end
|
124
127
|
|
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
|
+
|
125
140
|
def source_metadata(options)
|
126
141
|
if options[:content_length]
|
127
142
|
return { content_length: options.delete(:content_length) }
|
@@ -138,6 +153,7 @@ module Aws
|
|
138
153
|
key = CGI.unescape(key)
|
139
154
|
opts = { bucket: bucket, key: key }
|
140
155
|
opts[:version_id] = version_id if version_id
|
156
|
+
opts[:part_number] = options[:part_number] if options[:part_number]
|
141
157
|
client.head_object(opts).to_h
|
142
158
|
end
|
143
159
|
|
@@ -315,26 +315,28 @@ module Aws
|
|
315
315
|
|
316
316
|
# @!group Fields
|
317
317
|
|
318
|
-
#
|
319
|
-
#
|
320
|
-
#
|
318
|
+
# @!method key(key)
|
319
|
+
# The key to use for the uploaded object. You can use `${filename}`
|
320
|
+
# as a variable in the key. This will be replaced with the name
|
321
|
+
# of the file as provided by the user.
|
321
322
|
#
|
322
|
-
#
|
323
|
-
#
|
324
|
-
#
|
323
|
+
# For example, if the key is given as `/user/betty/${filename}` and
|
324
|
+
# the file uploaded is named `lolcatz.jpg`, the resultant key will
|
325
|
+
# be `/user/betty/lolcatz.jpg`.
|
325
326
|
#
|
326
|
-
#
|
327
|
-
#
|
328
|
-
#
|
327
|
+
# @param [String] key
|
328
|
+
# @see http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html)
|
329
|
+
# @return [self]
|
329
330
|
define_field(:key) do |key|
|
330
331
|
@key_set = true
|
331
332
|
with('key', key)
|
332
333
|
end
|
333
334
|
|
334
|
-
#
|
335
|
-
#
|
336
|
-
#
|
337
|
-
#
|
335
|
+
# @!method key_starts_with(prefix)
|
336
|
+
# Specify a prefix the uploaded
|
337
|
+
# @param [String] prefix
|
338
|
+
# @see #key
|
339
|
+
# @return [self]
|
338
340
|
define_field(:key_starts_with) do |prefix|
|
339
341
|
@key_set = true
|
340
342
|
starts_with('key', prefix)
|
@@ -412,26 +414,29 @@ module Aws
|
|
412
414
|
# @return [self]
|
413
415
|
define_field(:content_encoding, 'Content-Encoding', starts_with: true)
|
414
416
|
|
415
|
-
#
|
416
|
-
#
|
417
|
-
#
|
418
|
-
#
|
419
|
-
#
|
420
|
-
#
|
417
|
+
# @!method expires(time)
|
418
|
+
# The date and time at which the object is no longer cacheable.
|
419
|
+
# @note This does not affect the expiration of the presigned post
|
420
|
+
# signature.
|
421
|
+
# @param [Time] time
|
422
|
+
# @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21
|
423
|
+
# @return [self]
|
421
424
|
define_field(:expires) do |time|
|
422
425
|
with('Expires', time.httpdate)
|
423
426
|
end
|
424
427
|
|
425
|
-
#
|
426
|
-
#
|
427
|
-
#
|
428
|
+
# @!method expires_starts_with(prefix)
|
429
|
+
# @param [String] prefix
|
430
|
+
# @see #expires
|
431
|
+
# @return [self]
|
428
432
|
define_field(:expires_starts_with) do |prefix|
|
429
433
|
starts_with('Expires', prefix)
|
430
434
|
end
|
431
435
|
|
432
|
-
#
|
433
|
-
#
|
434
|
-
#
|
436
|
+
# @!method content_length_range(byte_range)
|
437
|
+
# The minimum and maximum allowable size for the uploaded content.
|
438
|
+
# @param [Range<Integer>] byte_range
|
439
|
+
# @return [self]
|
435
440
|
define_field(:content_length_range) do |byte_range|
|
436
441
|
min = byte_range.begin
|
437
442
|
max = byte_range.end
|
@@ -507,10 +512,11 @@ module Aws
|
|
507
512
|
# @return [self]
|
508
513
|
define_field(:website_redirect_location, 'x-amz-website-redirect-location')
|
509
514
|
|
510
|
-
#
|
511
|
-
#
|
512
|
-
#
|
513
|
-
#
|
515
|
+
# @!method metadata(hash)
|
516
|
+
# Metadata hash to store with the uploaded object. Hash keys will be
|
517
|
+
# prefixed with "x-amz-meta-".
|
518
|
+
# @param [Hash<String,String>] hash
|
519
|
+
# @return [self]
|
514
520
|
define_field(:metadata) do |hash|
|
515
521
|
hash.each do |key, value|
|
516
522
|
with("x-amz-meta-#{key}", value)
|
@@ -518,10 +524,11 @@ module Aws
|
|
518
524
|
self
|
519
525
|
end
|
520
526
|
|
521
|
-
#
|
522
|
-
#
|
523
|
-
#
|
524
|
-
#
|
527
|
+
# @!method metadata_starts_with(hash)
|
528
|
+
# Specify allowable prefix for each key in the metadata hash.
|
529
|
+
# @param [Hash<String,String>] hash
|
530
|
+
# @see #metadata
|
531
|
+
# @return [self]
|
525
532
|
define_field(:metadata_starts_with) do |hash|
|
526
533
|
hash.each do |key, value|
|
527
534
|
starts_with("x-amz-meta-#{key}", value)
|
@@ -571,24 +578,26 @@ module Aws
|
|
571
578
|
'x-amz-server-side-encryption-customer-algorithm'
|
572
579
|
)
|
573
580
|
|
574
|
-
#
|
575
|
-
#
|
576
|
-
#
|
581
|
+
# @!method server_side_encryption_customer_key(value)
|
582
|
+
# Specifies the customer-provided encryption key for Amazon S3 to use
|
583
|
+
# in encrypting data. This value is used to store the object and then
|
584
|
+
# it is discarded; Amazon does not store the encryption key.
|
577
585
|
#
|
578
|
-
#
|
586
|
+
# You must also call {#server_side_encryption_customer_algorithm}.
|
579
587
|
#
|
580
|
-
#
|
581
|
-
#
|
582
|
-
#
|
588
|
+
# @param [String] value
|
589
|
+
# @see #server_side_encryption_customer_algorithm
|
590
|
+
# @return [self]
|
583
591
|
define_field(:server_side_encryption_customer_key) do |value|
|
584
592
|
field_name = 'x-amz-server-side-encryption-customer-key'
|
585
593
|
with(field_name, base64(value))
|
586
594
|
with(field_name + '-MD5', base64(OpenSSL::Digest::MD5.digest(value)))
|
587
595
|
end
|
588
596
|
|
589
|
-
#
|
590
|
-
#
|
591
|
-
#
|
597
|
+
# @!method server_side_encryption_customer_key_starts_with(prefix)
|
598
|
+
# @param [String] prefix
|
599
|
+
# @see #server_side_encryption_customer_key
|
600
|
+
# @return [self]
|
592
601
|
define_field(:server_side_encryption_customer_key_starts_with) do |prefix|
|
593
602
|
field_name = 'x-amz-server-side-encryption-customer-key'
|
594
603
|
starts_with(field_name, prefix)
|
data/lib/aws-sdk-s3/resource.rb
CHANGED
@@ -41,7 +41,7 @@ module Aws::S3
|
|
41
41
|
# acl: "private", # accepts private, public-read, public-read-write, authenticated-read
|
42
42
|
# bucket: "BucketName", # required
|
43
43
|
# create_bucket_configuration: {
|
44
|
-
# location_constraint: "af-south-1", # accepts af-south-1, ap-east-1, ap-northeast-1, ap-northeast-2, ap-northeast-3, ap-south-1, ap-southeast-1, ap-southeast-2, ap-southeast-3, ca-central-1, cn-north-1, cn-northwest-1, EU, eu-central-1, eu-north-1, eu-south-1, eu-west-1, eu-west-2, eu-west-3, me-south-1, sa-east-1, us-east-2, us-gov-east-1, us-gov-west-1, us-west-1, us-west-2
|
44
|
+
# location_constraint: "af-south-1", # accepts af-south-1, ap-east-1, ap-northeast-1, ap-northeast-2, ap-northeast-3, ap-south-1, ap-southeast-1, ap-southeast-2, ap-southeast-3, ca-central-1, cn-north-1, cn-northwest-1, EU, eu-central-1, eu-north-1, eu-south-1, eu-west-1, eu-west-2, eu-west-3, me-south-1, sa-east-1, us-east-2, us-gov-east-1, us-gov-west-1, us-west-1, us-west-2, ap-south-2, eu-south-2
|
45
45
|
# },
|
46
46
|
# grant_full_control: "GrantFullControl",
|
47
47
|
# grant_read: "GrantRead",
|
data/lib/aws-sdk-s3.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-sdk-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.131.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amazon Web Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-kms
|