aws-sdk-s3 1.61.2 → 1.83.1
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 +5 -5
- data/lib/aws-sdk-s3.rb +5 -2
- data/lib/aws-sdk-s3/arn/access_point_arn.rb +62 -0
- data/lib/aws-sdk-s3/arn/outpost_access_point_arn.rb +71 -0
- data/lib/aws-sdk-s3/bucket.rb +61 -10
- data/lib/aws-sdk-s3/bucket_acl.rb +7 -0
- data/lib/aws-sdk-s3/bucket_cors.rb +15 -2
- data/lib/aws-sdk-s3/bucket_lifecycle.rb +14 -1
- data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +14 -1
- data/lib/aws-sdk-s3/bucket_logging.rb +7 -0
- data/lib/aws-sdk-s3/bucket_notification.rb +7 -0
- data/lib/aws-sdk-s3/bucket_policy.rb +14 -1
- data/lib/aws-sdk-s3/bucket_region_cache.rb +2 -0
- data/lib/aws-sdk-s3/bucket_request_payment.rb +7 -0
- data/lib/aws-sdk-s3/bucket_tagging.rb +14 -1
- data/lib/aws-sdk-s3/bucket_versioning.rb +17 -0
- data/lib/aws-sdk-s3/bucket_website.rb +18 -3
- data/lib/aws-sdk-s3/client.rb +2521 -1187
- data/lib/aws-sdk-s3/client_api.rb +188 -18
- data/lib/aws-sdk-s3/customizations.rb +3 -0
- data/lib/aws-sdk-s3/customizations/bucket.rb +11 -4
- data/lib/aws-sdk-s3/customizations/multipart_upload.rb +2 -0
- data/lib/aws-sdk-s3/customizations/object.rb +23 -5
- data/lib/aws-sdk-s3/customizations/object_summary.rb +5 -0
- data/lib/aws-sdk-s3/customizations/types/list_object_versions_output.rb +2 -0
- data/lib/aws-sdk-s3/encryption.rb +4 -0
- data/lib/aws-sdk-s3/encryption/client.rb +18 -5
- data/lib/aws-sdk-s3/encryption/decrypt_handler.rb +72 -26
- data/lib/aws-sdk-s3/encryption/default_cipher_provider.rb +43 -5
- data/lib/aws-sdk-s3/encryption/default_key_provider.rb +2 -0
- data/lib/aws-sdk-s3/encryption/encrypt_handler.rb +13 -2
- data/lib/aws-sdk-s3/encryption/errors.rb +2 -0
- data/lib/aws-sdk-s3/encryption/io_auth_decrypter.rb +2 -0
- data/lib/aws-sdk-s3/encryption/io_decrypter.rb +11 -3
- data/lib/aws-sdk-s3/encryption/io_encrypter.rb +2 -0
- data/lib/aws-sdk-s3/encryption/key_provider.rb +2 -0
- data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +34 -3
- data/lib/aws-sdk-s3/encryption/materials.rb +8 -6
- data/lib/aws-sdk-s3/encryption/utils.rb +25 -0
- data/lib/aws-sdk-s3/encryptionV2/client.rb +566 -0
- data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +226 -0
- data/lib/aws-sdk-s3/encryptionV2/default_cipher_provider.rb +170 -0
- data/lib/aws-sdk-s3/encryptionV2/default_key_provider.rb +40 -0
- data/lib/aws-sdk-s3/encryptionV2/encrypt_handler.rb +69 -0
- data/lib/aws-sdk-s3/encryptionV2/errors.rb +37 -0
- data/lib/aws-sdk-s3/encryptionV2/io_auth_decrypter.rb +58 -0
- data/lib/aws-sdk-s3/encryptionV2/io_decrypter.rb +37 -0
- data/lib/aws-sdk-s3/encryptionV2/io_encrypter.rb +73 -0
- data/lib/aws-sdk-s3/encryptionV2/key_provider.rb +31 -0
- data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +169 -0
- data/lib/aws-sdk-s3/encryptionV2/materials.rb +60 -0
- data/lib/aws-sdk-s3/encryptionV2/utils.rb +103 -0
- data/lib/aws-sdk-s3/encryption_v2.rb +23 -0
- data/lib/aws-sdk-s3/errors.rb +2 -0
- data/lib/aws-sdk-s3/event_streams.rb +7 -0
- data/lib/aws-sdk-s3/file_downloader.rb +10 -8
- data/lib/aws-sdk-s3/file_part.rb +2 -0
- data/lib/aws-sdk-s3/file_uploader.rb +14 -1
- data/lib/aws-sdk-s3/legacy_signer.rb +2 -0
- data/lib/aws-sdk-s3/multipart_file_uploader.rb +39 -2
- data/lib/aws-sdk-s3/multipart_stream_uploader.rb +3 -1
- data/lib/aws-sdk-s3/multipart_upload.rb +18 -1
- data/lib/aws-sdk-s3/multipart_upload_error.rb +2 -0
- data/lib/aws-sdk-s3/multipart_upload_part.rb +66 -7
- data/lib/aws-sdk-s3/object.rb +174 -23
- data/lib/aws-sdk-s3/object_acl.rb +15 -0
- data/lib/aws-sdk-s3/object_copier.rb +2 -0
- data/lib/aws-sdk-s3/object_multipart_copier.rb +2 -0
- data/lib/aws-sdk-s3/object_summary.rb +185 -20
- data/lib/aws-sdk-s3/object_version.rb +44 -4
- data/lib/aws-sdk-s3/plugins/accelerate.rb +29 -38
- data/lib/aws-sdk-s3/plugins/arn.rb +187 -0
- data/lib/aws-sdk-s3/plugins/bucket_dns.rb +2 -2
- data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +3 -1
- data/lib/aws-sdk-s3/plugins/dualstack.rb +5 -1
- data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +3 -4
- data/lib/aws-sdk-s3/plugins/get_bucket_location_fix.rb +2 -0
- data/lib/aws-sdk-s3/plugins/http_200_errors.rb +11 -3
- data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +3 -1
- data/lib/aws-sdk-s3/plugins/location_constraint.rb +2 -0
- data/lib/aws-sdk-s3/plugins/md5s.rb +26 -25
- data/lib/aws-sdk-s3/plugins/redirects.rb +2 -0
- data/lib/aws-sdk-s3/plugins/s3_host_id.rb +2 -0
- data/lib/aws-sdk-s3/plugins/s3_signer.rb +31 -7
- data/lib/aws-sdk-s3/plugins/sse_cpk.rb +3 -1
- data/lib/aws-sdk-s3/plugins/streaming_retry.rb +118 -0
- data/lib/aws-sdk-s3/plugins/url_encoded_keys.rb +2 -0
- data/lib/aws-sdk-s3/presigned_post.rb +68 -32
- data/lib/aws-sdk-s3/presigner.rb +102 -34
- data/lib/aws-sdk-s3/resource.rb +4 -2
- data/lib/aws-sdk-s3/types.rb +2016 -256
- data/lib/aws-sdk-s3/waiters.rb +2 -0
- metadata +23 -6
- data/lib/aws-sdk-s3/plugins/bucket_arn.rb +0 -211
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'openssl'
|
|
4
|
+
|
|
5
|
+
module Aws
|
|
6
|
+
module S3
|
|
7
|
+
module EncryptionV2
|
|
8
|
+
# @api private
|
|
9
|
+
module Utils
|
|
10
|
+
|
|
11
|
+
class << self
|
|
12
|
+
|
|
13
|
+
def encrypt_aes_gcm(key, data, auth_data)
|
|
14
|
+
cipher = aes_encryption_cipher(:GCM, key)
|
|
15
|
+
cipher.iv = (iv = cipher.random_iv)
|
|
16
|
+
cipher.auth_data = auth_data
|
|
17
|
+
|
|
18
|
+
iv + cipher.update(data) + cipher.final + cipher.auth_tag
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def encrypt_rsa(key, data, auth_data)
|
|
22
|
+
# Plaintext must be KeyLengthInBytes (1 Byte) + DataKey + AuthData
|
|
23
|
+
buf = [data.bytesize] + data.unpack('C*') + auth_data.unpack('C*')
|
|
24
|
+
key.public_encrypt(buf.pack('C*'), OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def decrypt(key, data)
|
|
28
|
+
begin
|
|
29
|
+
case key
|
|
30
|
+
when OpenSSL::PKey::RSA # asymmetric decryption
|
|
31
|
+
key.private_decrypt(data)
|
|
32
|
+
when String # symmetric Decryption
|
|
33
|
+
cipher = aes_cipher(:decrypt, :ECB, key, nil)
|
|
34
|
+
cipher.update(data) + cipher.final
|
|
35
|
+
end
|
|
36
|
+
rescue OpenSSL::Cipher::CipherError
|
|
37
|
+
msg = 'decryption failed, possible incorrect key'
|
|
38
|
+
raise Errors::DecryptionError, msg
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def decrypt_aes_gcm(key, data, auth_data)
|
|
43
|
+
# data is iv (12B) + key + tag (16B)
|
|
44
|
+
buf = data.unpack('C*')
|
|
45
|
+
iv = buf[0,12].pack('C*') # iv will always be 12 bytes
|
|
46
|
+
tag = buf[-16, 16].pack('C*') # tag is 16 bytes
|
|
47
|
+
enc_key = buf[12, buf.size - (12+16)].pack('C*')
|
|
48
|
+
cipher = aes_cipher(:decrypt, :GCM, key, iv)
|
|
49
|
+
cipher.auth_tag = tag
|
|
50
|
+
cipher.auth_data = auth_data
|
|
51
|
+
cipher.update(enc_key) + cipher.final
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# returns the decrypted data + auth_data
|
|
55
|
+
def decrypt_rsa(key, enc_data)
|
|
56
|
+
# Plaintext must be KeyLengthInBytes (1 Byte) + DataKey + AuthData
|
|
57
|
+
buf = key.private_decrypt(enc_data, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING).unpack('C*')
|
|
58
|
+
key_length = buf[0]
|
|
59
|
+
data = buf[1, key_length].pack('C*')
|
|
60
|
+
auth_data = buf[key_length+1, buf.length - key_length].pack('C*')
|
|
61
|
+
[data, auth_data]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# @param [String] block_mode "CBC" or "ECB"
|
|
65
|
+
# @param [OpenSSL::PKey::RSA, String, nil] key
|
|
66
|
+
# @param [String, nil] iv The initialization vector
|
|
67
|
+
def aes_encryption_cipher(block_mode, key = nil, iv = nil)
|
|
68
|
+
aes_cipher(:encrypt, block_mode, key, iv)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# @param [String] block_mode "CBC" or "ECB"
|
|
72
|
+
# @param [OpenSSL::PKey::RSA, String, nil] key
|
|
73
|
+
# @param [String, nil] iv The initialization vector
|
|
74
|
+
def aes_decryption_cipher(block_mode, key = nil, iv = nil)
|
|
75
|
+
aes_cipher(:decrypt, block_mode, key, iv)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# @param [String] mode "encrypt" or "decrypt"
|
|
79
|
+
# @param [String] block_mode "CBC" or "ECB"
|
|
80
|
+
# @param [OpenSSL::PKey::RSA, String, nil] key
|
|
81
|
+
# @param [String, nil] iv The initialization vector
|
|
82
|
+
def aes_cipher(mode, block_mode, key, iv)
|
|
83
|
+
cipher = key ?
|
|
84
|
+
OpenSSL::Cipher.new("aes-#{cipher_size(key)}-#{block_mode.downcase}") :
|
|
85
|
+
OpenSSL::Cipher.new("aes-256-#{block_mode.downcase}")
|
|
86
|
+
cipher.send(mode) # encrypt or decrypt
|
|
87
|
+
cipher.key = key if key
|
|
88
|
+
cipher.iv = iv if iv
|
|
89
|
+
cipher
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# @param [String] key
|
|
93
|
+
# @return [Integer]
|
|
94
|
+
# @raise ArgumentError
|
|
95
|
+
def cipher_size(key)
|
|
96
|
+
key.bytesize * 8
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'aws-sdk-s3/encryptionV2/client'
|
|
2
|
+
require 'aws-sdk-s3/encryptionV2/decrypt_handler'
|
|
3
|
+
require 'aws-sdk-s3/encryptionV2/default_cipher_provider'
|
|
4
|
+
require 'aws-sdk-s3/encryptionV2/encrypt_handler'
|
|
5
|
+
require 'aws-sdk-s3/encryptionV2/errors'
|
|
6
|
+
require 'aws-sdk-s3/encryptionV2/io_encrypter'
|
|
7
|
+
require 'aws-sdk-s3/encryptionV2/io_decrypter'
|
|
8
|
+
require 'aws-sdk-s3/encryptionV2/io_auth_decrypter'
|
|
9
|
+
require 'aws-sdk-s3/encryptionV2/key_provider'
|
|
10
|
+
require 'aws-sdk-s3/encryptionV2/kms_cipher_provider'
|
|
11
|
+
require 'aws-sdk-s3/encryptionV2/materials'
|
|
12
|
+
require 'aws-sdk-s3/encryptionV2/utils'
|
|
13
|
+
require 'aws-sdk-s3/encryptionV2/default_key_provider'
|
|
14
|
+
|
|
15
|
+
module Aws
|
|
16
|
+
module S3
|
|
17
|
+
module EncryptionV2
|
|
18
|
+
AES_GCM_TAG_LEN_BYTES = 16
|
|
19
|
+
EC_USER_AGENT = 'S3CryptoV2'
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
data/lib/aws-sdk-s3/errors.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# WARNING ABOUT GENERATED CODE
|
|
2
4
|
#
|
|
3
5
|
# This file is generated. See the contributing guide for more information:
|
|
@@ -41,6 +43,10 @@ module Aws::S3
|
|
|
41
43
|
@event_emitter.on(:initial_response, block) if block_given?
|
|
42
44
|
end
|
|
43
45
|
|
|
46
|
+
def on_unknown_event(&block)
|
|
47
|
+
@event_emitter.on(:unknown_event, block) if block_given?
|
|
48
|
+
end
|
|
49
|
+
|
|
44
50
|
def on_event(&block)
|
|
45
51
|
on_records_event(&block)
|
|
46
52
|
on_stats_event(&block)
|
|
@@ -49,6 +55,7 @@ module Aws::S3
|
|
|
49
55
|
on_end_event(&block)
|
|
50
56
|
on_error_event(&block)
|
|
51
57
|
on_initial_response_event(&block)
|
|
58
|
+
on_unknown_event(&block)
|
|
52
59
|
end
|
|
53
60
|
|
|
54
61
|
# @api private
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'pathname'
|
|
2
4
|
require 'thread'
|
|
3
5
|
require 'set'
|
|
@@ -21,7 +23,7 @@ module Aws
|
|
|
21
23
|
|
|
22
24
|
def download(destination, options = {})
|
|
23
25
|
@path = destination
|
|
24
|
-
@mode = options[:mode] ||
|
|
26
|
+
@mode = options[:mode] || 'auto'
|
|
25
27
|
@thread_count = options[:thread_count] || THREAD_COUNT
|
|
26
28
|
@chunk_size = options[:chunk_size]
|
|
27
29
|
@params = {
|
|
@@ -31,19 +33,19 @@ module Aws
|
|
|
31
33
|
@params[:version_id] = options[:version_id] if options[:version_id]
|
|
32
34
|
|
|
33
35
|
case @mode
|
|
34
|
-
when
|
|
35
|
-
when
|
|
36
|
-
when
|
|
36
|
+
when 'auto' then multipart_download
|
|
37
|
+
when 'single_request' then single_request
|
|
38
|
+
when 'get_range'
|
|
37
39
|
if @chunk_size
|
|
38
40
|
resp = @client.head_object(@params)
|
|
39
41
|
multithreaded_get_by_ranges(construct_chunks(resp.content_length))
|
|
40
42
|
else
|
|
41
|
-
msg =
|
|
43
|
+
msg = 'In :get_range mode, :chunk_size must be provided'
|
|
42
44
|
raise ArgumentError, msg
|
|
43
45
|
end
|
|
44
46
|
else
|
|
45
47
|
msg = "Invalid mode #{@mode} provided, "\
|
|
46
|
-
|
|
48
|
+
'mode should be :single_request, :get_range or :auto'
|
|
47
49
|
raise ArgumentError, msg
|
|
48
50
|
end
|
|
49
51
|
end
|
|
@@ -125,8 +127,8 @@ module Aws
|
|
|
125
127
|
end
|
|
126
128
|
|
|
127
129
|
def write(resp)
|
|
128
|
-
range, _ = resp.content_range.split(
|
|
129
|
-
head, _ = range.split(
|
|
130
|
+
range, _ = resp.content_range.split(' ').last.split('/')
|
|
131
|
+
head, _ = range.split('-').map {|s| s.to_i}
|
|
130
132
|
IO.write(@path, resp.body.read, head)
|
|
131
133
|
end
|
|
132
134
|
|
data/lib/aws-sdk-s3/file_part.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'pathname'
|
|
2
4
|
|
|
3
5
|
module Aws
|
|
@@ -20,13 +22,16 @@ module Aws
|
|
|
20
22
|
# @return [Client]
|
|
21
23
|
attr_reader :client
|
|
22
24
|
|
|
23
|
-
# @return [Integer] Files larger than this in bytes are uploaded
|
|
25
|
+
# @return [Integer] Files larger than or equal to this in bytes are uploaded
|
|
24
26
|
# using a {MultipartFileUploader}.
|
|
25
27
|
attr_reader :multipart_threshold
|
|
26
28
|
|
|
27
29
|
# @param [String, Pathname, File, Tempfile] source The file to upload.
|
|
28
30
|
# @option options [required, String] :bucket The bucket to upload to.
|
|
29
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]
|
|
30
35
|
# @return [void]
|
|
31
36
|
def upload(source, options = {})
|
|
32
37
|
if File.size(source) >= multipart_threshold
|
|
@@ -47,11 +52,19 @@ module Aws
|
|
|
47
52
|
end
|
|
48
53
|
|
|
49
54
|
def put_object(source, options)
|
|
55
|
+
if (callback = options.delete(:progress_callback))
|
|
56
|
+
options[:on_chunk_sent] = single_part_progress(callback)
|
|
57
|
+
end
|
|
50
58
|
open_file(source) do |file|
|
|
51
59
|
@client.put_object(options.merge(body: file))
|
|
52
60
|
end
|
|
53
61
|
end
|
|
54
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
|
|
55
68
|
end
|
|
56
69
|
end
|
|
57
70
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'pathname'
|
|
2
4
|
require 'set'
|
|
3
5
|
|
|
@@ -37,6 +39,9 @@ module Aws
|
|
|
37
39
|
# @param [String, Pathname, File, Tempfile] source The file to upload.
|
|
38
40
|
# @option options [required, String] :bucket The bucket to upload to.
|
|
39
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]
|
|
40
45
|
# @return [void]
|
|
41
46
|
def upload(source, options = {})
|
|
42
47
|
if File.size(source) < MIN_PART_SIZE
|
|
@@ -66,7 +71,7 @@ module Aws
|
|
|
66
71
|
def upload_parts(upload_id, source, options)
|
|
67
72
|
pending = PartList.new(compute_parts(upload_id, source, options))
|
|
68
73
|
completed = PartList.new
|
|
69
|
-
errors = upload_in_threads(pending, completed)
|
|
74
|
+
errors = upload_in_threads(pending, completed, options)
|
|
70
75
|
if errors.empty?
|
|
71
76
|
completed.to_a.sort_by { |part| part[:part_number] }
|
|
72
77
|
else
|
|
@@ -125,12 +130,21 @@ module Aws
|
|
|
125
130
|
end
|
|
126
131
|
end
|
|
127
132
|
|
|
128
|
-
def upload_in_threads(pending, completed)
|
|
133
|
+
def upload_in_threads(pending, completed, options)
|
|
129
134
|
threads = []
|
|
135
|
+
if (callback = options[:progress_callback])
|
|
136
|
+
progress = MultipartProgress.new(pending, callback)
|
|
137
|
+
end
|
|
130
138
|
@thread_count.times do
|
|
131
139
|
thread = Thread.new do
|
|
132
140
|
begin
|
|
133
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
|
|
134
148
|
resp = @client.upload_part(part)
|
|
135
149
|
part[:body].close
|
|
136
150
|
completed.push(etag: resp.etag, part_number: part[:part_number])
|
|
@@ -180,11 +194,34 @@ module Aws
|
|
|
180
194
|
@mutex.synchronize { @parts.clear }
|
|
181
195
|
end
|
|
182
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
|
+
|
|
183
205
|
def to_a
|
|
184
206
|
@mutex.synchronize { @parts.dup }
|
|
185
207
|
end
|
|
186
208
|
|
|
187
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
|
|
188
225
|
end
|
|
189
226
|
end
|
|
190
227
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'thread'
|
|
2
4
|
require 'set'
|
|
3
5
|
require 'tempfile'
|
|
@@ -113,7 +115,7 @@ module Aws
|
|
|
113
115
|
|
|
114
116
|
def read_to_part_body(read_pipe)
|
|
115
117
|
return if read_pipe.closed?
|
|
116
|
-
temp_io = @tempfile ? Tempfile.new(TEMPFILE_PREIX) : StringIO.new
|
|
118
|
+
temp_io = @tempfile ? Tempfile.new(TEMPFILE_PREIX) : StringIO.new(String.new)
|
|
117
119
|
temp_io.binmode
|
|
118
120
|
bytes_copied = IO.copy_stream(read_pipe, temp_io, @part_size)
|
|
119
121
|
temp_io.rewind
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# WARNING ABOUT GENERATED CODE
|
|
2
4
|
#
|
|
3
5
|
# This file is generated. See the contributing guide for more information:
|
|
@@ -218,6 +220,7 @@ module Aws::S3
|
|
|
218
220
|
#
|
|
219
221
|
# multipart_upload.abort({
|
|
220
222
|
# request_payer: "requester", # accepts requester
|
|
223
|
+
# expected_bucket_owner: "AccountId",
|
|
221
224
|
# })
|
|
222
225
|
# @param [Hash] options ({})
|
|
223
226
|
# @option options [String] :request_payer
|
|
@@ -230,6 +233,10 @@ module Aws::S3
|
|
|
230
233
|
#
|
|
231
234
|
#
|
|
232
235
|
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
|
236
|
+
# @option options [String] :expected_bucket_owner
|
|
237
|
+
# The account id of the expected bucket owner. If the bucket is owned by
|
|
238
|
+
# a different account, the request will fail with an HTTP `403 (Access
|
|
239
|
+
# Denied)` error.
|
|
233
240
|
# @return [Types::AbortMultipartUploadOutput]
|
|
234
241
|
def abort(options = {})
|
|
235
242
|
options = options.merge(
|
|
@@ -253,6 +260,7 @@ module Aws::S3
|
|
|
253
260
|
# ],
|
|
254
261
|
# },
|
|
255
262
|
# request_payer: "requester", # accepts requester
|
|
263
|
+
# expected_bucket_owner: "AccountId",
|
|
256
264
|
# })
|
|
257
265
|
# @param [Hash] options ({})
|
|
258
266
|
# @option options [Types::CompletedMultipartUpload] :multipart_upload
|
|
@@ -267,6 +275,10 @@ module Aws::S3
|
|
|
267
275
|
#
|
|
268
276
|
#
|
|
269
277
|
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
|
278
|
+
# @option options [String] :expected_bucket_owner
|
|
279
|
+
# The account id of the expected bucket owner. If the bucket is owned by
|
|
280
|
+
# a different account, the request will fail with an HTTP `403 (Access
|
|
281
|
+
# Denied)` error.
|
|
270
282
|
# @return [Object]
|
|
271
283
|
def complete(options = {})
|
|
272
284
|
options = options.merge(
|
|
@@ -274,7 +286,7 @@ module Aws::S3
|
|
|
274
286
|
key: @object_key,
|
|
275
287
|
upload_id: @id
|
|
276
288
|
)
|
|
277
|
-
|
|
289
|
+
@client.complete_multipart_upload(options)
|
|
278
290
|
Object.new(
|
|
279
291
|
bucket_name: @bucket_name,
|
|
280
292
|
key: @object_key,
|
|
@@ -309,6 +321,7 @@ module Aws::S3
|
|
|
309
321
|
#
|
|
310
322
|
# parts = multipart_upload.parts({
|
|
311
323
|
# request_payer: "requester", # accepts requester
|
|
324
|
+
# expected_bucket_owner: "AccountId",
|
|
312
325
|
# })
|
|
313
326
|
# @param [Hash] options ({})
|
|
314
327
|
# @option options [String] :request_payer
|
|
@@ -321,6 +334,10 @@ module Aws::S3
|
|
|
321
334
|
#
|
|
322
335
|
#
|
|
323
336
|
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
|
337
|
+
# @option options [String] :expected_bucket_owner
|
|
338
|
+
# The account id of the expected bucket owner. If the bucket is owned by
|
|
339
|
+
# a different account, the request will fail with an HTTP `403 (Access
|
|
340
|
+
# Denied)` error.
|
|
324
341
|
# @return [MultipartUploadPart::Collection]
|
|
325
342
|
def parts(options = {})
|
|
326
343
|
batches = Enumerator.new do |y|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# WARNING ABOUT GENERATED CODE
|
|
2
4
|
#
|
|
3
5
|
# This file is generated. See the contributing guide for more information:
|
|
@@ -219,11 +221,55 @@ module Aws::S3
|
|
|
219
221
|
# copy_source_sse_customer_key: "CopySourceSSECustomerKey",
|
|
220
222
|
# copy_source_sse_customer_key_md5: "CopySourceSSECustomerKeyMD5",
|
|
221
223
|
# request_payer: "requester", # accepts requester
|
|
224
|
+
# expected_bucket_owner: "AccountId",
|
|
225
|
+
# expected_source_bucket_owner: "AccountId",
|
|
222
226
|
# })
|
|
223
227
|
# @param [Hash] options ({})
|
|
224
228
|
# @option options [required, String] :copy_source
|
|
225
|
-
#
|
|
226
|
-
#
|
|
229
|
+
# Specifies the source object for the copy operation. You specify the
|
|
230
|
+
# value in one of two formats, depending on whether you want to access
|
|
231
|
+
# the source object through an [access point][1]\:
|
|
232
|
+
#
|
|
233
|
+
# * For objects not accessed through an access point, specify the name
|
|
234
|
+
# of the source bucket and key of the source object, separated by a
|
|
235
|
+
# slash (/). For example, to copy the object `reports/january.pdf`
|
|
236
|
+
# from the bucket `awsexamplebucket`, use
|
|
237
|
+
# `awsexamplebucket/reports/january.pdf`. The value must be URL
|
|
238
|
+
# encoded.
|
|
239
|
+
#
|
|
240
|
+
# * For objects accessed through access points, specify the Amazon
|
|
241
|
+
# Resource Name (ARN) of the object as accessed through the access
|
|
242
|
+
# point, in the format
|
|
243
|
+
# `arn:aws:s3:<Region>:<account-id>:accesspoint/<access-point-name>/object/<key>`.
|
|
244
|
+
# For example, to copy the object `reports/january.pdf` through access
|
|
245
|
+
# point `my-access-point` owned by account `123456789012` in Region
|
|
246
|
+
# `us-west-2`, use the URL encoding of
|
|
247
|
+
# `arn:aws:s3:us-west-2:123456789012:accesspoint/my-access-point/object/reports/january.pdf`.
|
|
248
|
+
# The value must be URL encoded.
|
|
249
|
+
#
|
|
250
|
+
# <note markdown="1"> Amazon S3 supports copy operations using access points only when the
|
|
251
|
+
# source and destination buckets are in the same AWS Region.
|
|
252
|
+
#
|
|
253
|
+
# </note>
|
|
254
|
+
#
|
|
255
|
+
# Alternatively, for objects accessed through Amazon S3 on Outposts,
|
|
256
|
+
# specify the ARN of the object as accessed in the format
|
|
257
|
+
# `arn:aws:s3-outposts:<Region>:<account-id>:outpost/<outpost-id>/object/<key>`.
|
|
258
|
+
# For example, to copy the object `reports/january.pdf` through
|
|
259
|
+
# outpost `my-outpost` owned by account `123456789012` in Region
|
|
260
|
+
# `us-west-2`, use the URL encoding of
|
|
261
|
+
# `arn:aws:s3-outposts:us-west-2:123456789012:outpost/my-outpost/object/reports/january.pdf`.
|
|
262
|
+
# The value must be URL encoded.
|
|
263
|
+
#
|
|
264
|
+
# To copy a specific version of an object, append
|
|
265
|
+
# `?versionId=<version-id>` to the value (for example,
|
|
266
|
+
# `awsexamplebucket/reports/january.pdf?versionId=QUpfdndhfd8438MNFDN93jdnJFkdmqnh893`).
|
|
267
|
+
# If you don't specify a version ID, Amazon S3 copies the latest
|
|
268
|
+
# version of the source object.
|
|
269
|
+
#
|
|
270
|
+
#
|
|
271
|
+
#
|
|
272
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/access-points.html
|
|
227
273
|
# @option options [String] :copy_source_if_match
|
|
228
274
|
# Copies the object if its entity tag (ETag) matches the specified tag.
|
|
229
275
|
# @option options [Time,DateTime,Date,Integer,String] :copy_source_if_modified_since
|
|
@@ -248,8 +294,8 @@ module Aws::S3
|
|
|
248
294
|
# encrypting data. This value is used to store the object and then it is
|
|
249
295
|
# discarded; Amazon S3 does not store the encryption key. The key must
|
|
250
296
|
# be appropriate for use with the algorithm specified in the
|
|
251
|
-
# `x-amz-server-side
|
|
252
|
-
#
|
|
297
|
+
# `x-amz-server-side-encryption-customer-algorithm` header. This must be
|
|
298
|
+
# the same encryption key specified in the initiate multipart upload
|
|
253
299
|
# request.
|
|
254
300
|
# @option options [String] :sse_customer_key_md5
|
|
255
301
|
# Specifies the 128-bit MD5 digest of the encryption key according to
|
|
@@ -276,6 +322,14 @@ module Aws::S3
|
|
|
276
322
|
#
|
|
277
323
|
#
|
|
278
324
|
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
|
325
|
+
# @option options [String] :expected_bucket_owner
|
|
326
|
+
# The account id of the expected destination bucket owner. If the
|
|
327
|
+
# destination bucket is owned by a different account, the request will
|
|
328
|
+
# fail with an HTTP `403 (Access Denied)` error.
|
|
329
|
+
# @option options [String] :expected_source_bucket_owner
|
|
330
|
+
# The account id of the expected source bucket owner. If the source
|
|
331
|
+
# bucket is owned by a different account, the request will fail with an
|
|
332
|
+
# HTTP `403 (Access Denied)` error.
|
|
279
333
|
# @return [Types::UploadPartCopyOutput]
|
|
280
334
|
def copy_from(options = {})
|
|
281
335
|
options = options.merge(
|
|
@@ -298,9 +352,10 @@ module Aws::S3
|
|
|
298
352
|
# sse_customer_key: "SSECustomerKey",
|
|
299
353
|
# sse_customer_key_md5: "SSECustomerKeyMD5",
|
|
300
354
|
# request_payer: "requester", # accepts requester
|
|
355
|
+
# expected_bucket_owner: "AccountId",
|
|
301
356
|
# })
|
|
302
357
|
# @param [Hash] options ({})
|
|
303
|
-
# @option options [String,
|
|
358
|
+
# @option options [String, StringIO, File] :body
|
|
304
359
|
# Object data.
|
|
305
360
|
# @option options [Integer] :content_length
|
|
306
361
|
# Size of the body in bytes. This parameter is useful when the size of
|
|
@@ -317,8 +372,8 @@ module Aws::S3
|
|
|
317
372
|
# encrypting data. This value is used to store the object and then it is
|
|
318
373
|
# discarded; Amazon S3 does not store the encryption key. The key must
|
|
319
374
|
# be appropriate for use with the algorithm specified in the
|
|
320
|
-
# `x-amz-server-side
|
|
321
|
-
#
|
|
375
|
+
# `x-amz-server-side-encryption-customer-algorithm header`. This must be
|
|
376
|
+
# the same encryption key specified in the initiate multipart upload
|
|
322
377
|
# request.
|
|
323
378
|
# @option options [String] :sse_customer_key_md5
|
|
324
379
|
# Specifies the 128-bit MD5 digest of the encryption key according to
|
|
@@ -334,6 +389,10 @@ module Aws::S3
|
|
|
334
389
|
#
|
|
335
390
|
#
|
|
336
391
|
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
|
392
|
+
# @option options [String] :expected_bucket_owner
|
|
393
|
+
# The account id of the expected bucket owner. If the bucket is owned by
|
|
394
|
+
# a different account, the request will fail with an HTTP `403 (Access
|
|
395
|
+
# Denied)` error.
|
|
337
396
|
# @return [Types::UploadPartOutput]
|
|
338
397
|
def upload(options = {})
|
|
339
398
|
options = options.merge(
|