aws-sdk-s3 1.198.0 → 1.202.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 +29 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-s3/bucket_versioning.rb +33 -0
- data/lib/aws-sdk-s3/client.rb +644 -155
- data/lib/aws-sdk-s3/client_api.rb +2 -0
- data/lib/aws-sdk-s3/customizations/object.rb +30 -20
- data/lib/aws-sdk-s3/customizations.rb +1 -0
- data/lib/aws-sdk-s3/default_executor.rb +103 -0
- data/lib/aws-sdk-s3/endpoint_parameters.rb +17 -17
- data/lib/aws-sdk-s3/file_downloader.rb +175 -112
- data/lib/aws-sdk-s3/file_uploader.rb +6 -8
- data/lib/aws-sdk-s3/multipart_file_uploader.rb +79 -63
- data/lib/aws-sdk-s3/multipart_stream_uploader.rb +41 -44
- data/lib/aws-sdk-s3/object.rb +52 -23
- data/lib/aws-sdk-s3/object_summary.rb +38 -9
- data/lib/aws-sdk-s3/object_version.rb +7 -9
- data/lib/aws-sdk-s3/plugins/endpoints.rb +1 -1
- data/lib/aws-sdk-s3/transfer_manager.rb +84 -26
- data/lib/aws-sdk-s3/types.rb +197 -141
- data/lib/aws-sdk-s3.rb +1 -1
- data/sig/client.rbs +2 -0
- data/sig/object.rbs +2 -0
- data/sig/object_summary.rbs +2 -0
- data/sig/types.rbs +2 -0
- metadata +4 -3
|
@@ -907,6 +907,8 @@ module Aws::S3
|
|
|
907
907
|
CopyObjectRequest.add_member(:grant_read, Shapes::ShapeRef.new(shape: GrantRead, location: "header", location_name: "x-amz-grant-read"))
|
|
908
908
|
CopyObjectRequest.add_member(:grant_read_acp, Shapes::ShapeRef.new(shape: GrantReadACP, location: "header", location_name: "x-amz-grant-read-acp"))
|
|
909
909
|
CopyObjectRequest.add_member(:grant_write_acp, Shapes::ShapeRef.new(shape: GrantWriteACP, location: "header", location_name: "x-amz-grant-write-acp"))
|
|
910
|
+
CopyObjectRequest.add_member(:if_match, Shapes::ShapeRef.new(shape: IfMatch, location: "header", location_name: "If-Match"))
|
|
911
|
+
CopyObjectRequest.add_member(:if_none_match, Shapes::ShapeRef.new(shape: IfNoneMatch, location: "header", location_name: "If-None-Match"))
|
|
910
912
|
CopyObjectRequest.add_member(:key, Shapes::ShapeRef.new(shape: ObjectKey, required: true, location: "uri", location_name: "Key", metadata: {"contextParam" => {"name" => "Key"}}))
|
|
911
913
|
CopyObjectRequest.add_member(:metadata, Shapes::ShapeRef.new(shape: Metadata, location: "headers", location_name: "x-amz-meta-"))
|
|
912
914
|
CopyObjectRequest.add_member(:metadata_directive, Shapes::ShapeRef.new(shape: MetadataDirective, location: "header", location_name: "x-amz-metadata-directive"))
|
|
@@ -358,8 +358,8 @@ module Aws
|
|
|
358
358
|
# {Client#complete_multipart_upload},
|
|
359
359
|
# and {Client#upload_part} can be provided.
|
|
360
360
|
#
|
|
361
|
-
# @option options [Integer] :thread_count (10) The number of parallel
|
|
362
|
-
#
|
|
361
|
+
# @option options [Integer] :thread_count (10) The number of parallel multipart uploads.
|
|
362
|
+
# An additional thread is used internally for task coordination.
|
|
363
363
|
#
|
|
364
364
|
# @option options [Boolean] :tempfile (false) Normally read data is stored
|
|
365
365
|
# in memory when building the parts in order to complete the underlying
|
|
@@ -383,19 +383,18 @@ module Aws
|
|
|
383
383
|
# @see Client#complete_multipart_upload
|
|
384
384
|
# @see Client#upload_part
|
|
385
385
|
def upload_stream(options = {}, &block)
|
|
386
|
-
|
|
386
|
+
upload_opts = options.merge(bucket: bucket_name, key: key)
|
|
387
|
+
executor = DefaultExecutor.new(max_threads: upload_opts.delete(:thread_count))
|
|
387
388
|
uploader = MultipartStreamUploader.new(
|
|
388
389
|
client: client,
|
|
389
|
-
|
|
390
|
-
tempfile:
|
|
391
|
-
part_size:
|
|
390
|
+
executor: executor,
|
|
391
|
+
tempfile: upload_opts.delete(:tempfile),
|
|
392
|
+
part_size: upload_opts.delete(:part_size)
|
|
392
393
|
)
|
|
393
394
|
Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
|
394
|
-
uploader.upload(
|
|
395
|
-
uploading_options.merge(bucket: bucket_name, key: key),
|
|
396
|
-
&block
|
|
397
|
-
)
|
|
395
|
+
uploader.upload(upload_opts, &block)
|
|
398
396
|
end
|
|
397
|
+
executor.shutdown
|
|
399
398
|
true
|
|
400
399
|
end
|
|
401
400
|
deprecated(:upload_stream, use: 'Aws::S3::TransferManager#upload_stream', version: 'next major version')
|
|
@@ -458,12 +457,18 @@ module Aws
|
|
|
458
457
|
# @see Client#complete_multipart_upload
|
|
459
458
|
# @see Client#upload_part
|
|
460
459
|
def upload_file(source, options = {})
|
|
461
|
-
|
|
462
|
-
|
|
460
|
+
upload_opts = options.merge(bucket: bucket_name, key: key)
|
|
461
|
+
executor = DefaultExecutor.new(max_threads: upload_opts.delete(:thread_count))
|
|
462
|
+
uploader = FileUploader.new(
|
|
463
|
+
client: client,
|
|
464
|
+
executor: executor,
|
|
465
|
+
multipart_threshold: upload_opts.delete(:multipart_threshold)
|
|
466
|
+
)
|
|
463
467
|
response = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
|
464
|
-
uploader.upload(source,
|
|
468
|
+
uploader.upload(source, upload_opts)
|
|
465
469
|
end
|
|
466
470
|
yield response if block_given?
|
|
471
|
+
executor.shutdown
|
|
467
472
|
true
|
|
468
473
|
end
|
|
469
474
|
deprecated(:upload_file, use: 'Aws::S3::TransferManager#upload_file', version: 'next major version')
|
|
@@ -491,7 +496,13 @@ module Aws
|
|
|
491
496
|
# @param [String, Pathname, File, Tempfile] destination
|
|
492
497
|
# Where to download the file to. This can either be a String or Pathname to the file, an open File object,
|
|
493
498
|
# or an open Tempfile object. If you pass an open File or Tempfile object, then you are responsible for
|
|
494
|
-
# closing it after the download completes.
|
|
499
|
+
# closing it after the download completes. Download behavior varies by destination type:
|
|
500
|
+
#
|
|
501
|
+
# * **String/Pathname paths**: Downloads to a temporary file first, then atomically moves to the final
|
|
502
|
+
# destination. This prevents corruption of any existing file if the download fails.
|
|
503
|
+
# * **File/Tempfile objects**: Downloads directly to the file object without using temporary files.
|
|
504
|
+
# You are responsible for managing the file object's state and closing it after the download completes.
|
|
505
|
+
# If the download fails, the file object may contain partial data.
|
|
495
506
|
#
|
|
496
507
|
# @param [Hash] options
|
|
497
508
|
# Additional options for {Client#get_object} and #{Client#head_object} may be provided.
|
|
@@ -506,10 +517,6 @@ module Aws
|
|
|
506
517
|
#
|
|
507
518
|
# @option options [Integer] :thread_count (10) Customize threads used in the multipart download.
|
|
508
519
|
#
|
|
509
|
-
# @option options [String] :version_id The object version id used to retrieve the object.
|
|
510
|
-
#
|
|
511
|
-
# @see https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectVersioning.html ObjectVersioning
|
|
512
|
-
#
|
|
513
520
|
# @option options [String] :checksum_mode ("ENABLED")
|
|
514
521
|
# When `"ENABLED"` and the object has a stored checksum, it will be used to validate the download and will
|
|
515
522
|
# raise an `Aws::Errors::ChecksumError` if checksum validation fails. You may provide a `on_checksum_validated`
|
|
@@ -533,10 +540,13 @@ module Aws
|
|
|
533
540
|
# @see Client#get_object
|
|
534
541
|
# @see Client#head_object
|
|
535
542
|
def download_file(destination, options = {})
|
|
536
|
-
|
|
543
|
+
download_opts = options.merge(bucket: bucket_name, key: key)
|
|
544
|
+
executor = DefaultExecutor.new(max_threads: download_opts.delete([:thread_count]))
|
|
545
|
+
downloader = FileDownloader.new(client: client, executor: executor)
|
|
537
546
|
Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
|
538
|
-
downloader.download(destination,
|
|
547
|
+
downloader.download(destination, download_opts)
|
|
539
548
|
end
|
|
549
|
+
executor.shutdown
|
|
540
550
|
true
|
|
541
551
|
end
|
|
542
552
|
deprecated(:download_file, use: 'Aws::S3::TransferManager#download_file', version: 'next major version')
|
|
@@ -7,6 +7,7 @@ module Aws
|
|
|
7
7
|
autoload :Encryption, 'aws-sdk-s3/encryption'
|
|
8
8
|
autoload :EncryptionV2, 'aws-sdk-s3/encryption_v2'
|
|
9
9
|
autoload :FilePart, 'aws-sdk-s3/file_part'
|
|
10
|
+
autoload :DefaultExecutor, 'aws-sdk-s3/default_executor'
|
|
10
11
|
autoload :FileUploader, 'aws-sdk-s3/file_uploader'
|
|
11
12
|
autoload :FileDownloader, 'aws-sdk-s3/file_downloader'
|
|
12
13
|
autoload :LegacySigner, 'aws-sdk-s3/legacy_signer'
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Aws
|
|
4
|
+
module S3
|
|
5
|
+
# @api private
|
|
6
|
+
class DefaultExecutor
|
|
7
|
+
DEFAULT_MAX_THREADS = 10
|
|
8
|
+
RUNNING = :running
|
|
9
|
+
SHUTTING_DOWN = :shutting_down
|
|
10
|
+
SHUTDOWN = :shutdown
|
|
11
|
+
|
|
12
|
+
def initialize(options = {})
|
|
13
|
+
@max_threads = options[:max_threads] || DEFAULT_MAX_THREADS
|
|
14
|
+
@state = RUNNING
|
|
15
|
+
@queue = Queue.new
|
|
16
|
+
@pool = []
|
|
17
|
+
@mutex = Mutex.new
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Submits a task for execution.
|
|
21
|
+
# @param [Object] args Variable number of arguments to pass to the block
|
|
22
|
+
# @param [Proc] block The block to be executed
|
|
23
|
+
# @return [Boolean] Returns true if the task was submitted successfully
|
|
24
|
+
def post(*args, &block)
|
|
25
|
+
@mutex.synchronize do
|
|
26
|
+
raise 'Executor has been shutdown and is no longer accepting tasks' unless @state == RUNNING
|
|
27
|
+
|
|
28
|
+
@queue << [args, block]
|
|
29
|
+
ensure_worker_available
|
|
30
|
+
end
|
|
31
|
+
true
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Immediately terminates all worker threads and clears pending tasks.
|
|
35
|
+
# This is a forceful shutdown that doesn't wait for running tasks to complete.
|
|
36
|
+
#
|
|
37
|
+
# @return [Boolean] true when termination is complete
|
|
38
|
+
def kill
|
|
39
|
+
@mutex.synchronize do
|
|
40
|
+
@state = SHUTDOWN
|
|
41
|
+
@pool.each(&:kill)
|
|
42
|
+
@pool.clear
|
|
43
|
+
@queue.clear
|
|
44
|
+
end
|
|
45
|
+
true
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Gracefully shuts down the executor, optionally with a timeout.
|
|
49
|
+
# Stops accepting new tasks and waits for running tasks to complete.
|
|
50
|
+
#
|
|
51
|
+
# @param timeout [Numeric, nil] Maximum time in seconds to wait for shutdown.
|
|
52
|
+
# If nil, waits indefinitely. If timeout expires, remaining threads are killed.
|
|
53
|
+
# @return [Boolean] true when shutdown is complete
|
|
54
|
+
def shutdown(timeout = nil)
|
|
55
|
+
@mutex.synchronize do
|
|
56
|
+
return true if @state == SHUTDOWN
|
|
57
|
+
|
|
58
|
+
@state = SHUTTING_DOWN
|
|
59
|
+
@pool.size.times { @queue << :shutdown }
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
if timeout
|
|
63
|
+
deadline = Time.now + timeout
|
|
64
|
+
@pool.each do |thread|
|
|
65
|
+
remaining = deadline - Time.now
|
|
66
|
+
break if remaining <= 0
|
|
67
|
+
|
|
68
|
+
thread.join([remaining, 0].max)
|
|
69
|
+
end
|
|
70
|
+
@pool.select(&:alive?).each(&:kill)
|
|
71
|
+
else
|
|
72
|
+
@pool.each(&:join)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
@mutex.synchronize do
|
|
76
|
+
@pool.clear
|
|
77
|
+
@state = SHUTDOWN
|
|
78
|
+
end
|
|
79
|
+
true
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
private
|
|
83
|
+
|
|
84
|
+
def ensure_worker_available
|
|
85
|
+
return unless @state == RUNNING
|
|
86
|
+
|
|
87
|
+
@pool.select!(&:alive?)
|
|
88
|
+
@pool << spawn_worker if @pool.size < @max_threads
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def spawn_worker
|
|
92
|
+
Thread.new do
|
|
93
|
+
while (job = @queue.shift)
|
|
94
|
+
break if job == :shutdown
|
|
95
|
+
|
|
96
|
+
args, block = job
|
|
97
|
+
block.call(*args)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -13,87 +13,87 @@ module Aws::S3
|
|
|
13
13
|
# @!attribute bucket
|
|
14
14
|
# The S3 bucket used to send the request. This is an optional parameter that will be set automatically for operations that are scoped to an S3 bucket.
|
|
15
15
|
#
|
|
16
|
-
# @return [
|
|
16
|
+
# @return [string]
|
|
17
17
|
#
|
|
18
18
|
# @!attribute region
|
|
19
19
|
# The AWS region used to dispatch the request.
|
|
20
20
|
#
|
|
21
|
-
# @return [
|
|
21
|
+
# @return [string]
|
|
22
22
|
#
|
|
23
23
|
# @!attribute use_fips
|
|
24
24
|
# When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.
|
|
25
25
|
#
|
|
26
|
-
# @return [
|
|
26
|
+
# @return [boolean]
|
|
27
27
|
#
|
|
28
28
|
# @!attribute use_dual_stack
|
|
29
29
|
# When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
|
|
30
30
|
#
|
|
31
|
-
# @return [
|
|
31
|
+
# @return [boolean]
|
|
32
32
|
#
|
|
33
33
|
# @!attribute endpoint
|
|
34
34
|
# Override the endpoint used to send this request
|
|
35
35
|
#
|
|
36
|
-
# @return [
|
|
36
|
+
# @return [string]
|
|
37
37
|
#
|
|
38
38
|
# @!attribute force_path_style
|
|
39
39
|
# When true, force a path-style endpoint to be used where the bucket name is part of the path.
|
|
40
40
|
#
|
|
41
|
-
# @return [
|
|
41
|
+
# @return [boolean]
|
|
42
42
|
#
|
|
43
43
|
# @!attribute accelerate
|
|
44
44
|
# When true, use S3 Accelerate. NOTE: Not all regions support S3 accelerate.
|
|
45
45
|
#
|
|
46
|
-
# @return [
|
|
46
|
+
# @return [boolean]
|
|
47
47
|
#
|
|
48
48
|
# @!attribute use_global_endpoint
|
|
49
49
|
# Whether the global endpoint should be used, rather then the regional endpoint for us-east-1.
|
|
50
50
|
#
|
|
51
|
-
# @return [
|
|
51
|
+
# @return [boolean]
|
|
52
52
|
#
|
|
53
53
|
# @!attribute use_object_lambda_endpoint
|
|
54
54
|
# Internal parameter to use object lambda endpoint for an operation (eg: WriteGetObjectResponse)
|
|
55
55
|
#
|
|
56
|
-
# @return [
|
|
56
|
+
# @return [boolean]
|
|
57
57
|
#
|
|
58
58
|
# @!attribute key
|
|
59
59
|
# The S3 Key used to send the request. This is an optional parameter that will be set automatically for operations that are scoped to an S3 Key.
|
|
60
60
|
#
|
|
61
|
-
# @return [
|
|
61
|
+
# @return [string]
|
|
62
62
|
#
|
|
63
63
|
# @!attribute prefix
|
|
64
64
|
# The S3 Prefix used to send the request. This is an optional parameter that will be set automatically for operations that are scoped to an S3 Prefix.
|
|
65
65
|
#
|
|
66
|
-
# @return [
|
|
66
|
+
# @return [string]
|
|
67
67
|
#
|
|
68
68
|
# @!attribute copy_source
|
|
69
69
|
# The Copy Source used for Copy Object request. This is an optional parameter that will be set automatically for operations that are scoped to Copy Source.
|
|
70
70
|
#
|
|
71
|
-
# @return [
|
|
71
|
+
# @return [string]
|
|
72
72
|
#
|
|
73
73
|
# @!attribute disable_access_points
|
|
74
74
|
# Internal parameter to disable Access Point Buckets
|
|
75
75
|
#
|
|
76
|
-
# @return [
|
|
76
|
+
# @return [boolean]
|
|
77
77
|
#
|
|
78
78
|
# @!attribute disable_multi_region_access_points
|
|
79
79
|
# Whether multi-region access points (MRAP) should be disabled.
|
|
80
80
|
#
|
|
81
|
-
# @return [
|
|
81
|
+
# @return [boolean]
|
|
82
82
|
#
|
|
83
83
|
# @!attribute use_arn_region
|
|
84
84
|
# When an Access Point ARN is provided and this flag is enabled, the SDK MUST use the ARN's region when constructing the endpoint instead of the client's configured region.
|
|
85
85
|
#
|
|
86
|
-
# @return [
|
|
86
|
+
# @return [boolean]
|
|
87
87
|
#
|
|
88
88
|
# @!attribute use_s3_express_control_endpoint
|
|
89
89
|
# Internal parameter to indicate whether S3Express operation should use control plane, (ex. CreateBucket)
|
|
90
90
|
#
|
|
91
|
-
# @return [
|
|
91
|
+
# @return [boolean]
|
|
92
92
|
#
|
|
93
93
|
# @!attribute disable_s3_express_session_auth
|
|
94
94
|
# Parameter to indicate whether S3Express session auth should be disabled
|
|
95
95
|
#
|
|
96
|
-
# @return [
|
|
96
|
+
# @return [boolean]
|
|
97
97
|
#
|
|
98
98
|
EndpointParameters = Struct.new(
|
|
99
99
|
:bucket,
|