aws-sdk-s3 1.36.1 → 1.56.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aws-sdk-s3/bucket.rb +158 -34
- data/lib/aws-sdk-s3/bucket_acl.rb +10 -1
- data/lib/aws-sdk-s3/bucket_cors.rb +17 -1
- data/lib/aws-sdk-s3/bucket_lifecycle.rb +1 -1
- data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +2 -1
- data/lib/aws-sdk-s3/bucket_logging.rb +10 -3
- data/lib/aws-sdk-s3/bucket_notification.rb +6 -3
- data/lib/aws-sdk-s3/bucket_policy.rb +1 -0
- data/lib/aws-sdk-s3/bucket_request_payment.rb +9 -0
- data/lib/aws-sdk-s3/bucket_tagging.rb +9 -1
- data/lib/aws-sdk-s3/bucket_versioning.rb +25 -0
- data/lib/aws-sdk-s3/bucket_website.rb +14 -4
- data/lib/aws-sdk-s3/client.rb +4636 -301
- data/lib/aws-sdk-s3/client_api.rb +22 -0
- data/lib/aws-sdk-s3/customizations/bucket.rb +4 -0
- data/lib/aws-sdk-s3/customizations/object.rb +65 -43
- data/lib/aws-sdk-s3/encryption/client.rb +4 -0
- data/lib/aws-sdk-s3/event_streams.rb +7 -7
- data/lib/aws-sdk-s3/file_part.rb +9 -6
- data/lib/aws-sdk-s3/file_uploader.rb +13 -12
- data/lib/aws-sdk-s3/multipart_file_uploader.rb +14 -11
- data/lib/aws-sdk-s3/multipart_upload.rb +3 -1
- data/lib/aws-sdk-s3/multipart_upload_part.rb +3 -1
- data/lib/aws-sdk-s3/object.rb +205 -32
- data/lib/aws-sdk-s3/object_acl.rb +17 -2
- data/lib/aws-sdk-s3/object_summary.rb +125 -25
- data/lib/aws-sdk-s3/object_version.rb +6 -2
- data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +59 -0
- data/lib/aws-sdk-s3/plugins/md5s.rb +3 -4
- data/lib/aws-sdk-s3/plugins/s3_signer.rb +2 -0
- data/lib/aws-sdk-s3/presigned_post.rb +4 -0
- data/lib/aws-sdk-s3/presigner.rb +44 -30
- data/lib/aws-sdk-s3/resource.rb +2 -0
- data/lib/aws-sdk-s3/types.rb +2460 -430
- data/lib/aws-sdk-s3.rb +1 -1
- metadata +7 -6
@@ -143,12 +143,15 @@ module Aws::S3
|
|
143
143
|
EncodingType = Shapes::StringShape.new(name: 'EncodingType')
|
144
144
|
Encryption = Shapes::StructureShape.new(name: 'Encryption')
|
145
145
|
EncryptionConfiguration = Shapes::StructureShape.new(name: 'EncryptionConfiguration')
|
146
|
+
End = Shapes::IntegerShape.new(name: 'End')
|
146
147
|
EndEvent = Shapes::StructureShape.new(name: 'EndEvent')
|
147
148
|
Error = Shapes::StructureShape.new(name: 'Error')
|
148
149
|
ErrorDocument = Shapes::StructureShape.new(name: 'ErrorDocument')
|
149
150
|
Errors = Shapes::ListShape.new(name: 'Errors', flattened: true)
|
150
151
|
Event = Shapes::StringShape.new(name: 'Event')
|
151
152
|
EventList = Shapes::ListShape.new(name: 'EventList', flattened: true)
|
153
|
+
ExistingObjectReplication = Shapes::StructureShape.new(name: 'ExistingObjectReplication')
|
154
|
+
ExistingObjectReplicationStatus = Shapes::StringShape.new(name: 'ExistingObjectReplicationStatus')
|
152
155
|
Expiration = Shapes::StringShape.new(name: 'Expiration')
|
153
156
|
ExpirationStatus = Shapes::StringShape.new(name: 'ExpirationStatus')
|
154
157
|
ExpiredObjectDeleteMarker = Shapes::BooleanShape.new(name: 'ExpiredObjectDeleteMarker')
|
@@ -460,8 +463,10 @@ module Aws::S3
|
|
460
463
|
SSECustomerKey = Shapes::StringShape.new(name: 'SSECustomerKey')
|
461
464
|
SSECustomerKeyMD5 = Shapes::StringShape.new(name: 'SSECustomerKeyMD5')
|
462
465
|
SSEKMS = Shapes::StructureShape.new(name: 'SSEKMS')
|
466
|
+
SSEKMSEncryptionContext = Shapes::StringShape.new(name: 'SSEKMSEncryptionContext')
|
463
467
|
SSEKMSKeyId = Shapes::StringShape.new(name: 'SSEKMSKeyId')
|
464
468
|
SSES3 = Shapes::StructureShape.new(name: 'SSES3')
|
469
|
+
ScanRange = Shapes::StructureShape.new(name: 'ScanRange')
|
465
470
|
SelectObjectContentEventStream = Shapes::StructureShape.new(name: 'SelectObjectContentEventStream')
|
466
471
|
SelectObjectContentOutput = Shapes::StructureShape.new(name: 'SelectObjectContentOutput')
|
467
472
|
SelectObjectContentRequest = Shapes::StructureShape.new(name: 'SelectObjectContentRequest')
|
@@ -476,6 +481,7 @@ module Aws::S3
|
|
476
481
|
SourceSelectionCriteria = Shapes::StructureShape.new(name: 'SourceSelectionCriteria')
|
477
482
|
SseKmsEncryptedObjects = Shapes::StructureShape.new(name: 'SseKmsEncryptedObjects')
|
478
483
|
SseKmsEncryptedObjectsStatus = Shapes::StringShape.new(name: 'SseKmsEncryptedObjectsStatus')
|
484
|
+
Start = Shapes::IntegerShape.new(name: 'Start')
|
479
485
|
StartAfter = Shapes::StringShape.new(name: 'StartAfter')
|
480
486
|
Stats = Shapes::StructureShape.new(name: 'Stats')
|
481
487
|
StatsEvent = Shapes::StructureShape.new(name: 'StatsEvent')
|
@@ -666,6 +672,7 @@ module Aws::S3
|
|
666
672
|
CopyObjectOutput.add_member(:sse_customer_algorithm, Shapes::ShapeRef.new(shape: SSECustomerAlgorithm, location: "header", location_name: "x-amz-server-side-encryption-customer-algorithm"))
|
667
673
|
CopyObjectOutput.add_member(:sse_customer_key_md5, Shapes::ShapeRef.new(shape: SSECustomerKeyMD5, location: "header", location_name: "x-amz-server-side-encryption-customer-key-MD5"))
|
668
674
|
CopyObjectOutput.add_member(:ssekms_key_id, Shapes::ShapeRef.new(shape: SSEKMSKeyId, location: "header", location_name: "x-amz-server-side-encryption-aws-kms-key-id"))
|
675
|
+
CopyObjectOutput.add_member(:ssekms_encryption_context, Shapes::ShapeRef.new(shape: SSEKMSEncryptionContext, location: "header", location_name: "x-amz-server-side-encryption-context"))
|
669
676
|
CopyObjectOutput.add_member(:request_charged, Shapes::ShapeRef.new(shape: RequestCharged, location: "header", location_name: "x-amz-request-charged"))
|
670
677
|
CopyObjectOutput.struct_class = Types::CopyObjectOutput
|
671
678
|
CopyObjectOutput[:payload] = :copy_object_result
|
@@ -699,6 +706,7 @@ module Aws::S3
|
|
699
706
|
CopyObjectRequest.add_member(:sse_customer_key, Shapes::ShapeRef.new(shape: SSECustomerKey, location: "header", location_name: "x-amz-server-side-encryption-customer-key"))
|
700
707
|
CopyObjectRequest.add_member(:sse_customer_key_md5, Shapes::ShapeRef.new(shape: SSECustomerKeyMD5, location: "header", location_name: "x-amz-server-side-encryption-customer-key-MD5"))
|
701
708
|
CopyObjectRequest.add_member(:ssekms_key_id, Shapes::ShapeRef.new(shape: SSEKMSKeyId, location: "header", location_name: "x-amz-server-side-encryption-aws-kms-key-id"))
|
709
|
+
CopyObjectRequest.add_member(:ssekms_encryption_context, Shapes::ShapeRef.new(shape: SSEKMSEncryptionContext, location: "header", location_name: "x-amz-server-side-encryption-context"))
|
702
710
|
CopyObjectRequest.add_member(:copy_source_sse_customer_algorithm, Shapes::ShapeRef.new(shape: CopySourceSSECustomerAlgorithm, location: "header", location_name: "x-amz-copy-source-server-side-encryption-customer-algorithm"))
|
703
711
|
CopyObjectRequest.add_member(:copy_source_sse_customer_key, Shapes::ShapeRef.new(shape: CopySourceSSECustomerKey, location: "header", location_name: "x-amz-copy-source-server-side-encryption-customer-key"))
|
704
712
|
CopyObjectRequest.add_member(:copy_source_sse_customer_key_md5, Shapes::ShapeRef.new(shape: CopySourceSSECustomerKeyMD5, location: "header", location_name: "x-amz-copy-source-server-side-encryption-customer-key-MD5"))
|
@@ -745,6 +753,7 @@ module Aws::S3
|
|
745
753
|
CreateMultipartUploadOutput.add_member(:sse_customer_algorithm, Shapes::ShapeRef.new(shape: SSECustomerAlgorithm, location: "header", location_name: "x-amz-server-side-encryption-customer-algorithm"))
|
746
754
|
CreateMultipartUploadOutput.add_member(:sse_customer_key_md5, Shapes::ShapeRef.new(shape: SSECustomerKeyMD5, location: "header", location_name: "x-amz-server-side-encryption-customer-key-MD5"))
|
747
755
|
CreateMultipartUploadOutput.add_member(:ssekms_key_id, Shapes::ShapeRef.new(shape: SSEKMSKeyId, location: "header", location_name: "x-amz-server-side-encryption-aws-kms-key-id"))
|
756
|
+
CreateMultipartUploadOutput.add_member(:ssekms_encryption_context, Shapes::ShapeRef.new(shape: SSEKMSEncryptionContext, location: "header", location_name: "x-amz-server-side-encryption-context"))
|
748
757
|
CreateMultipartUploadOutput.add_member(:request_charged, Shapes::ShapeRef.new(shape: RequestCharged, location: "header", location_name: "x-amz-request-charged"))
|
749
758
|
CreateMultipartUploadOutput.struct_class = Types::CreateMultipartUploadOutput
|
750
759
|
|
@@ -769,6 +778,7 @@ module Aws::S3
|
|
769
778
|
CreateMultipartUploadRequest.add_member(:sse_customer_key, Shapes::ShapeRef.new(shape: SSECustomerKey, location: "header", location_name: "x-amz-server-side-encryption-customer-key"))
|
770
779
|
CreateMultipartUploadRequest.add_member(:sse_customer_key_md5, Shapes::ShapeRef.new(shape: SSECustomerKeyMD5, location: "header", location_name: "x-amz-server-side-encryption-customer-key-MD5"))
|
771
780
|
CreateMultipartUploadRequest.add_member(:ssekms_key_id, Shapes::ShapeRef.new(shape: SSEKMSKeyId, location: "header", location_name: "x-amz-server-side-encryption-aws-kms-key-id"))
|
781
|
+
CreateMultipartUploadRequest.add_member(:ssekms_encryption_context, Shapes::ShapeRef.new(shape: SSEKMSEncryptionContext, location: "header", location_name: "x-amz-server-side-encryption-context"))
|
772
782
|
CreateMultipartUploadRequest.add_member(:request_payer, Shapes::ShapeRef.new(shape: RequestPayer, location: "header", location_name: "x-amz-request-payer"))
|
773
783
|
CreateMultipartUploadRequest.add_member(:tagging, Shapes::ShapeRef.new(shape: TaggingHeader, location: "header", location_name: "x-amz-tagging"))
|
774
784
|
CreateMultipartUploadRequest.add_member(:object_lock_mode, Shapes::ShapeRef.new(shape: ObjectLockMode, location: "header", location_name: "x-amz-object-lock-mode"))
|
@@ -909,6 +919,9 @@ module Aws::S3
|
|
909
919
|
|
910
920
|
EventList.member = Shapes::ShapeRef.new(shape: Event)
|
911
921
|
|
922
|
+
ExistingObjectReplication.add_member(:status, Shapes::ShapeRef.new(shape: ExistingObjectReplicationStatus, required: true, location_name: "Status"))
|
923
|
+
ExistingObjectReplication.struct_class = Types::ExistingObjectReplication
|
924
|
+
|
912
925
|
ExposeHeaders.member = Shapes::ShapeRef.new(shape: ExposeHeader)
|
913
926
|
|
914
927
|
FilterRule.add_member(:name, Shapes::ShapeRef.new(shape: FilterRuleName, location_name: "Name"))
|
@@ -1719,6 +1732,7 @@ module Aws::S3
|
|
1719
1732
|
PutBucketReplicationRequest.add_member(:bucket, Shapes::ShapeRef.new(shape: BucketName, required: true, location: "uri", location_name: "Bucket"))
|
1720
1733
|
PutBucketReplicationRequest.add_member(:content_md5, Shapes::ShapeRef.new(shape: ContentMD5, location: "header", location_name: "Content-MD5"))
|
1721
1734
|
PutBucketReplicationRequest.add_member(:replication_configuration, Shapes::ShapeRef.new(shape: ReplicationConfiguration, required: true, location_name: "ReplicationConfiguration", metadata: {"xmlNamespace"=>{"uri"=>"http://s3.amazonaws.com/doc/2006-03-01/"}}))
|
1735
|
+
PutBucketReplicationRequest.add_member(:token, Shapes::ShapeRef.new(shape: ObjectLockToken, location: "header", location_name: "x-amz-bucket-object-lock-token"))
|
1722
1736
|
PutBucketReplicationRequest.struct_class = Types::PutBucketReplicationRequest
|
1723
1737
|
PutBucketReplicationRequest[:payload] = :replication_configuration
|
1724
1738
|
PutBucketReplicationRequest[:payload_member] = PutBucketReplicationRequest.member(:replication_configuration)
|
@@ -1803,6 +1817,7 @@ module Aws::S3
|
|
1803
1817
|
PutObjectOutput.add_member(:sse_customer_algorithm, Shapes::ShapeRef.new(shape: SSECustomerAlgorithm, location: "header", location_name: "x-amz-server-side-encryption-customer-algorithm"))
|
1804
1818
|
PutObjectOutput.add_member(:sse_customer_key_md5, Shapes::ShapeRef.new(shape: SSECustomerKeyMD5, location: "header", location_name: "x-amz-server-side-encryption-customer-key-MD5"))
|
1805
1819
|
PutObjectOutput.add_member(:ssekms_key_id, Shapes::ShapeRef.new(shape: SSEKMSKeyId, location: "header", location_name: "x-amz-server-side-encryption-aws-kms-key-id"))
|
1820
|
+
PutObjectOutput.add_member(:ssekms_encryption_context, Shapes::ShapeRef.new(shape: SSEKMSEncryptionContext, location: "header", location_name: "x-amz-server-side-encryption-context"))
|
1806
1821
|
PutObjectOutput.add_member(:request_charged, Shapes::ShapeRef.new(shape: RequestCharged, location: "header", location_name: "x-amz-request-charged"))
|
1807
1822
|
PutObjectOutput.struct_class = Types::PutObjectOutput
|
1808
1823
|
|
@@ -1830,6 +1845,7 @@ module Aws::S3
|
|
1830
1845
|
PutObjectRequest.add_member(:sse_customer_key, Shapes::ShapeRef.new(shape: SSECustomerKey, location: "header", location_name: "x-amz-server-side-encryption-customer-key"))
|
1831
1846
|
PutObjectRequest.add_member(:sse_customer_key_md5, Shapes::ShapeRef.new(shape: SSECustomerKeyMD5, location: "header", location_name: "x-amz-server-side-encryption-customer-key-MD5"))
|
1832
1847
|
PutObjectRequest.add_member(:ssekms_key_id, Shapes::ShapeRef.new(shape: SSEKMSKeyId, location: "header", location_name: "x-amz-server-side-encryption-aws-kms-key-id"))
|
1848
|
+
PutObjectRequest.add_member(:ssekms_encryption_context, Shapes::ShapeRef.new(shape: SSEKMSEncryptionContext, location: "header", location_name: "x-amz-server-side-encryption-context"))
|
1833
1849
|
PutObjectRequest.add_member(:request_payer, Shapes::ShapeRef.new(shape: RequestPayer, location: "header", location_name: "x-amz-request-payer"))
|
1834
1850
|
PutObjectRequest.add_member(:tagging, Shapes::ShapeRef.new(shape: TaggingHeader, location: "header", location_name: "x-amz-tagging"))
|
1835
1851
|
PutObjectRequest.add_member(:object_lock_mode, Shapes::ShapeRef.new(shape: ObjectLockMode, location: "header", location_name: "x-amz-object-lock-mode"))
|
@@ -1910,6 +1926,7 @@ module Aws::S3
|
|
1910
1926
|
ReplicationRule.add_member(:filter, Shapes::ShapeRef.new(shape: ReplicationRuleFilter, location_name: "Filter"))
|
1911
1927
|
ReplicationRule.add_member(:status, Shapes::ShapeRef.new(shape: ReplicationRuleStatus, required: true, location_name: "Status"))
|
1912
1928
|
ReplicationRule.add_member(:source_selection_criteria, Shapes::ShapeRef.new(shape: SourceSelectionCriteria, location_name: "SourceSelectionCriteria"))
|
1929
|
+
ReplicationRule.add_member(:existing_object_replication, Shapes::ShapeRef.new(shape: ExistingObjectReplication, location_name: "ExistingObjectReplication"))
|
1913
1930
|
ReplicationRule.add_member(:destination, Shapes::ShapeRef.new(shape: Destination, required: true, location_name: "Destination"))
|
1914
1931
|
ReplicationRule.add_member(:delete_marker_replication, Shapes::ShapeRef.new(shape: DeleteMarkerReplication, location_name: "DeleteMarkerReplication"))
|
1915
1932
|
ReplicationRule.struct_class = Types::ReplicationRule
|
@@ -1989,6 +2006,10 @@ module Aws::S3
|
|
1989
2006
|
|
1990
2007
|
SSES3.struct_class = Types::SSES3
|
1991
2008
|
|
2009
|
+
ScanRange.add_member(:start, Shapes::ShapeRef.new(shape: Start, location_name: "Start"))
|
2010
|
+
ScanRange.add_member(:end, Shapes::ShapeRef.new(shape: End, location_name: "End"))
|
2011
|
+
ScanRange.struct_class = Types::ScanRange
|
2012
|
+
|
1992
2013
|
SelectObjectContentEventStream.add_member(:records, Shapes::ShapeRef.new(shape: RecordsEvent, event: true, location_name: "Records"))
|
1993
2014
|
SelectObjectContentEventStream.add_member(:stats, Shapes::ShapeRef.new(shape: StatsEvent, event: true, location_name: "Stats"))
|
1994
2015
|
SelectObjectContentEventStream.add_member(:progress, Shapes::ShapeRef.new(shape: ProgressEvent, event: true, location_name: "Progress"))
|
@@ -2011,6 +2032,7 @@ module Aws::S3
|
|
2011
2032
|
SelectObjectContentRequest.add_member(:request_progress, Shapes::ShapeRef.new(shape: RequestProgress, location_name: "RequestProgress"))
|
2012
2033
|
SelectObjectContentRequest.add_member(:input_serialization, Shapes::ShapeRef.new(shape: InputSerialization, required: true, location_name: "InputSerialization"))
|
2013
2034
|
SelectObjectContentRequest.add_member(:output_serialization, Shapes::ShapeRef.new(shape: OutputSerialization, required: true, location_name: "OutputSerialization"))
|
2035
|
+
SelectObjectContentRequest.add_member(:scan_range, Shapes::ShapeRef.new(shape: ScanRange, location_name: "ScanRange"))
|
2014
2036
|
SelectObjectContentRequest.struct_class = Types::SelectObjectContentRequest
|
2015
2037
|
|
2016
2038
|
SelectParameters.add_member(:input_serialization, Shapes::ShapeRef.new(shape: InputSerialization, required: true, location_name: "InputSerialization"))
|
@@ -114,6 +114,10 @@ module Aws
|
|
114
114
|
url.path += '/' unless url.path[-1] == '/'
|
115
115
|
url.path += Seahorse::Util.uri_escape(name)
|
116
116
|
end
|
117
|
+
if (client.config.region == 'us-east-1') &&
|
118
|
+
(client.config.s3_us_east_1_regional_endpoint == 'legacy')
|
119
|
+
url.host = Plugins::IADRegionalEndpoint.legacy_host(url.host)
|
120
|
+
end
|
117
121
|
url.to_s
|
118
122
|
end
|
119
123
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Aws
|
2
2
|
module S3
|
3
3
|
class Object
|
4
|
-
|
5
4
|
alias size content_length
|
6
5
|
|
7
6
|
# Copies another object to this object. Use `multipart_copy: true`
|
8
7
|
# for large objects. This is required for objects that exceed 5GB.
|
9
8
|
#
|
10
|
-
# @param [S3::Object, S3::ObjectVersion, S3::ObjectSummary, String, Hash]
|
11
|
-
# Where to copy object data from. `source` must be one of the
|
9
|
+
# @param [S3::Object, S3::ObjectVersion, S3::ObjectSummary, String, Hash]
|
10
|
+
# source Where to copy object data from. `source` must be one of the
|
11
|
+
# following:
|
12
12
|
#
|
13
13
|
# * {Aws::S3::Object}
|
14
14
|
# * {Aws::S3::ObjectSummary}
|
@@ -103,8 +103,9 @@ module Aws
|
|
103
103
|
ObjectCopier.new(self, options).copy_to(target, options)
|
104
104
|
end
|
105
105
|
|
106
|
-
# Copies and deletes the current object. The object will only be
|
107
|
-
#
|
106
|
+
# Copies and deletes the current object. The object will only be deleted
|
107
|
+
# if the copy operation succeeds.
|
108
|
+
#
|
108
109
|
# @param (see Object#copy_to)
|
109
110
|
# @option (see Object#copy_to)
|
110
111
|
# @return [void]
|
@@ -129,10 +130,7 @@ module Aws
|
|
129
130
|
client.config.credentials,
|
130
131
|
client.config.region,
|
131
132
|
bucket_name,
|
132
|
-
{
|
133
|
-
key: key,
|
134
|
-
url: bucket.url,
|
135
|
-
}.merge(options)
|
133
|
+
{ key: key, url: bucket.url }.merge(options)
|
136
134
|
)
|
137
135
|
end
|
138
136
|
|
@@ -186,10 +184,10 @@ module Aws
|
|
186
184
|
#
|
187
185
|
def presigned_url(http_method, params = {})
|
188
186
|
presigner = Presigner.new(client: client)
|
189
|
-
presigner.presigned_url(
|
190
|
-
|
191
|
-
key: key
|
192
|
-
)
|
187
|
+
presigner.presigned_url(
|
188
|
+
"#{http_method.downcase}_object",
|
189
|
+
params.merge(bucket: bucket_name, key: key)
|
190
|
+
)
|
193
191
|
end
|
194
192
|
|
195
193
|
# Returns the public (un-signed) URL for this object.
|
@@ -199,7 +197,8 @@ module Aws
|
|
199
197
|
#
|
200
198
|
# To use virtual hosted bucket url (disables https):
|
201
199
|
#
|
202
|
-
# s3.bucket('my.bucket.com').object('key')
|
200
|
+
# s3.bucket('my.bucket.com').object('key')
|
201
|
+
# .public_url(virtual_host: true)
|
203
202
|
# #=> "http://my.bucket.com/key"
|
204
203
|
#
|
205
204
|
# @option options [Boolean] :virtual_host (false) When `true`, the bucket
|
@@ -216,11 +215,12 @@ module Aws
|
|
216
215
|
|
217
216
|
# Uploads a stream in a streaming fashion to the current object in S3.
|
218
217
|
#
|
219
|
-
#
|
220
|
-
#
|
221
|
-
#
|
218
|
+
# Passed chunks automatically split into multipart upload parts and the
|
219
|
+
# parts are uploaded in parallel. This allows for streaming uploads that
|
220
|
+
# never touch the disk.
|
222
221
|
#
|
223
|
-
#
|
222
|
+
# Note that this is known to have issues in JRuby until jruby-9.1.15.0,
|
223
|
+
# so avoid using this with older versions of JRuby.
|
224
224
|
#
|
225
225
|
# @example Streaming chunks of data
|
226
226
|
# obj.upload_stream do |write_stream|
|
@@ -235,17 +235,15 @@ module Aws
|
|
235
235
|
# IO.copy_stream(STDIN, write_stream)
|
236
236
|
# end
|
237
237
|
#
|
238
|
-
# @option options [Integer] :thread_count
|
239
|
-
#
|
240
|
-
# Default `:thread_count` is `10`.
|
238
|
+
# @option options [Integer] :thread_count (10) The number of parallel
|
239
|
+
# multipart uploads
|
241
240
|
#
|
242
|
-
# @option options [Boolean] :tempfile
|
243
|
-
#
|
244
|
-
#
|
241
|
+
# @option options [Boolean] :tempfile (false) Normally read data is stored
|
242
|
+
# in memory when building the parts in order to complete the underlying
|
243
|
+
# multipart upload. By passing `:tempfile => true` data read will be
|
245
244
|
# temporarily stored on disk reducing the memory footprint vastly.
|
246
|
-
# Default `:tempfile` is `false`.
|
247
245
|
#
|
248
|
-
# @option options [Integer] :part_size
|
246
|
+
# @option options [Integer] :part_size (5242880)
|
249
247
|
# Define how big each part size but the last should be.
|
250
248
|
# Default `:part_size` is `5 * 1024 * 1024`.
|
251
249
|
#
|
@@ -264,9 +262,12 @@ module Aws
|
|
264
262
|
client: client,
|
265
263
|
thread_count: uploading_options.delete(:thread_count),
|
266
264
|
tempfile: uploading_options.delete(:tempfile),
|
267
|
-
part_size: uploading_options.delete(:part_size)
|
265
|
+
part_size: uploading_options.delete(:part_size)
|
266
|
+
)
|
267
|
+
uploader.upload(
|
268
|
+
uploading_options.merge(bucket: bucket_name, key: key),
|
269
|
+
&block
|
268
270
|
)
|
269
|
-
uploader.upload(uploading_options.merge(bucket: bucket_name, key: key), &block)
|
270
271
|
true
|
271
272
|
end
|
272
273
|
|
@@ -282,15 +283,29 @@ module Aws
|
|
282
283
|
# # and the parts are uploaded in parallel
|
283
284
|
# obj.upload_file('/path/to/very_large_file')
|
284
285
|
#
|
285
|
-
#
|
286
|
-
#
|
287
|
-
#
|
288
|
-
#
|
286
|
+
# The response of the S3 upload API is yielded if a block given.
|
287
|
+
#
|
288
|
+
# # API response will have etag value of the file
|
289
|
+
# obj.upload_file('/path/to/file') do |response|
|
290
|
+
# etag = response.etag
|
291
|
+
# end
|
292
|
+
#
|
293
|
+
# @param [String, Pathname, File, Tempfile] source A file on the local
|
294
|
+
# file system that will be uploaded as this object. This can either be
|
295
|
+
# a String or Pathname to the file, an open File object, or an open
|
296
|
+
# Tempfile object. If you pass an open File or Tempfile object, then
|
297
|
+
# you are responsible for closing it after the upload completes. When
|
298
|
+
# using an open Tempfile, rewind it before uploading or else the object
|
299
|
+
# will be empty.
|
289
300
|
#
|
290
301
|
# @option options [Integer] :multipart_threshold (15728640) Files larger
|
291
302
|
# than `:multipart_threshold` are uploaded using the S3 multipart APIs.
|
292
303
|
# Default threshold is 15MB.
|
293
304
|
#
|
305
|
+
# @option options [Integer] :thread_count (10) The number of parallel
|
306
|
+
# multipart uploads. This option is not used if the file is smaller than
|
307
|
+
# `:multipart_threshold`.
|
308
|
+
#
|
294
309
|
# @raise [MultipartUploadError] If an object is being uploaded in
|
295
310
|
# parts, and the upload can not be completed, then the upload is
|
296
311
|
# aborted and this error is raised. The raised error has a `#errors`
|
@@ -304,8 +319,13 @@ module Aws
|
|
304
319
|
uploading_options = options.dup
|
305
320
|
uploader = FileUploader.new(
|
306
321
|
multipart_threshold: uploading_options.delete(:multipart_threshold),
|
307
|
-
client: client
|
308
|
-
|
322
|
+
client: client
|
323
|
+
)
|
324
|
+
response = uploader.upload(
|
325
|
+
source,
|
326
|
+
uploading_options.merge(bucket: bucket_name, key: key)
|
327
|
+
)
|
328
|
+
yield response if block_given?
|
309
329
|
true
|
310
330
|
end
|
311
331
|
|
@@ -320,7 +340,7 @@ module Aws
|
|
320
340
|
# # and the parts are downloaded in parallel
|
321
341
|
# obj.download_file('/path/to/very_large_file')
|
322
342
|
#
|
323
|
-
# @param [String] destination Where to download the file to
|
343
|
+
# @param [String] destination Where to download the file to.
|
324
344
|
#
|
325
345
|
# @option options [String] mode `auto`, `single_request`, `get_range`
|
326
346
|
# `single_request` mode forces only 1 GET request is made in download,
|
@@ -328,21 +348,23 @@ module Aws
|
|
328
348
|
# customizing each range size in multipart_download,
|
329
349
|
# By default, `auto` mode is enabled, which performs multipart_download
|
330
350
|
#
|
331
|
-
# @option options [String] chunk_size required in get_range mode
|
351
|
+
# @option options [String] chunk_size required in get_range mode.
|
332
352
|
#
|
333
|
-
# @option options [
|
334
|
-
#
|
353
|
+
# @option options [Integer] thread_count (10) Customize threads used in
|
354
|
+
# the multipart download.
|
335
355
|
#
|
336
|
-
# @option options [String] version_id The object version id used to
|
337
|
-
# the object
|
356
|
+
# @option options [String] version_id The object version id used to
|
357
|
+
# retrieve the object. For more about object versioning, see:
|
338
358
|
# https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectVersioning.html
|
339
359
|
#
|
340
|
-
# @return [Boolean] Returns `true` when the file is downloaded
|
341
|
-
#
|
360
|
+
# @return [Boolean] Returns `true` when the file is downloaded without
|
361
|
+
# any errors.
|
342
362
|
def download_file(destination, options = {})
|
343
363
|
downloader = FileDownloader.new(client: client)
|
344
364
|
downloader.download(
|
345
|
-
destination,
|
365
|
+
destination,
|
366
|
+
options.merge(bucket: bucket_name, key: key)
|
367
|
+
)
|
346
368
|
true
|
347
369
|
end
|
348
370
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
1
3
|
module Aws
|
2
4
|
module S3
|
3
5
|
|
@@ -178,6 +180,8 @@ module Aws
|
|
178
180
|
class Client
|
179
181
|
|
180
182
|
extend Deprecations
|
183
|
+
extend Forwardable
|
184
|
+
def_delegators :@client, :delete_object, :head_object
|
181
185
|
|
182
186
|
# Creates a new encryption client. You must provide one of the following
|
183
187
|
# options:
|
@@ -14,31 +14,31 @@ module Aws::S3
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def on_records_event(&block)
|
17
|
-
@event_emitter.on(:records,
|
17
|
+
@event_emitter.on(:records, block) if block_given?
|
18
18
|
end
|
19
19
|
|
20
20
|
def on_stats_event(&block)
|
21
|
-
@event_emitter.on(:stats,
|
21
|
+
@event_emitter.on(:stats, block) if block_given?
|
22
22
|
end
|
23
23
|
|
24
24
|
def on_progress_event(&block)
|
25
|
-
@event_emitter.on(:progress,
|
25
|
+
@event_emitter.on(:progress, block) if block_given?
|
26
26
|
end
|
27
27
|
|
28
28
|
def on_cont_event(&block)
|
29
|
-
@event_emitter.on(:cont,
|
29
|
+
@event_emitter.on(:cont, block) if block_given?
|
30
30
|
end
|
31
31
|
|
32
32
|
def on_end_event(&block)
|
33
|
-
@event_emitter.on(:end,
|
33
|
+
@event_emitter.on(:end, block) if block_given?
|
34
34
|
end
|
35
35
|
|
36
36
|
def on_error_event(&block)
|
37
|
-
@event_emitter.on(:error,
|
37
|
+
@event_emitter.on(:error, block) if block_given?
|
38
38
|
end
|
39
39
|
|
40
40
|
def on_initial_response_event(&block)
|
41
|
-
@event_emitter.on(:initial_response,
|
41
|
+
@event_emitter.on(:initial_response, block) if block_given?
|
42
42
|
end
|
43
43
|
|
44
44
|
def on_event(&block)
|
data/lib/aws-sdk-s3/file_part.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
module Aws
|
2
2
|
module S3
|
3
3
|
|
4
|
-
# A utility class that provides an IO-like interface to a portion of
|
5
|
-
#
|
4
|
+
# A utility class that provides an IO-like interface to a portion of a file
|
5
|
+
# on disk.
|
6
6
|
# @api private
|
7
7
|
class FilePart
|
8
8
|
|
9
|
-
# @option options [required,String,Pathname,File,Tempfile] :source
|
10
|
-
#
|
9
|
+
# @option options [required, String, Pathname, File, Tempfile] :source
|
10
|
+
# The file to upload.
|
11
|
+
#
|
12
|
+
# @option options [required, Integer] :offset The file part will read
|
11
13
|
# starting at this byte offset.
|
12
|
-
#
|
14
|
+
#
|
15
|
+
# @option options [required, Integer] :size The maximum number of bytes to
|
13
16
|
# read from the `:offset`.
|
14
17
|
def initialize(options = {})
|
15
18
|
@source = options[:source]
|
@@ -19,7 +22,7 @@ module Aws
|
|
19
22
|
@file = nil
|
20
23
|
end
|
21
24
|
|
22
|
-
# @return [String,Pathname,File,Tempfile]
|
25
|
+
# @return [String, Pathname, File, Tempfile]
|
23
26
|
attr_reader :source
|
24
27
|
|
25
28
|
# @return [Integer]
|
@@ -7,13 +7,14 @@ module Aws
|
|
7
7
|
|
8
8
|
FIFTEEN_MEGABYTES = 15 * 1024 * 1024
|
9
9
|
|
10
|
+
# @param [Hash] options
|
10
11
|
# @option options [Client] :client
|
11
|
-
# @option options [Integer] :multipart_threshold
|
12
|
-
# `:multipart_threshold` bytes are uploaded using S3 multipart APIs.
|
12
|
+
# @option options [Integer] :multipart_threshold (15728640)
|
13
13
|
def initialize(options = {})
|
14
14
|
@options = options
|
15
15
|
@client = options[:client] || Client.new
|
16
|
-
@multipart_threshold = options[:multipart_threshold] ||
|
16
|
+
@multipart_threshold = options[:multipart_threshold] ||
|
17
|
+
FIFTEEN_MEGABYTES
|
17
18
|
end
|
18
19
|
|
19
20
|
# @return [Client]
|
@@ -23,9 +24,9 @@ module Aws
|
|
23
24
|
# using a {MultipartFileUploader}.
|
24
25
|
attr_reader :multipart_threshold
|
25
26
|
|
26
|
-
# @param [String,Pathname,File,Tempfile] source
|
27
|
-
# @option options [required,String] :bucket
|
28
|
-
# @option options [required,String] :key
|
27
|
+
# @param [String, Pathname, File, Tempfile] source The file to upload.
|
28
|
+
# @option options [required, String] :bucket The bucket to upload to.
|
29
|
+
# @option options [required, String] :key The key for the object.
|
29
30
|
# @return [void]
|
30
31
|
def upload(source, options = {})
|
31
32
|
if File.size(source) >= multipart_threshold
|
@@ -37,12 +38,6 @@ module Aws
|
|
37
38
|
|
38
39
|
private
|
39
40
|
|
40
|
-
def put_object(source, options)
|
41
|
-
open_file(source) do |file|
|
42
|
-
@client.put_object(options.merge(body: file))
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
41
|
def open_file(source)
|
47
42
|
if String === source || Pathname === source
|
48
43
|
File.open(source, 'rb') { |file| yield(file) }
|
@@ -51,6 +46,12 @@ module Aws
|
|
51
46
|
end
|
52
47
|
end
|
53
48
|
|
49
|
+
def put_object(source, options)
|
50
|
+
open_file(source) do |file|
|
51
|
+
@client.put_object(options.merge(body: file))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
54
55
|
end
|
55
56
|
end
|
56
57
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'pathname'
|
2
|
-
require 'thread'
|
3
2
|
require 'set'
|
4
3
|
|
5
4
|
module Aws
|
@@ -16,14 +15,17 @@ module Aws
|
|
16
15
|
THREAD_COUNT = 10
|
17
16
|
|
18
17
|
# @api private
|
19
|
-
CREATE_OPTIONS =
|
20
|
-
|
18
|
+
CREATE_OPTIONS = Set.new(
|
19
|
+
Client.api.operation(:create_multipart_upload).input.shape.member_names
|
20
|
+
)
|
21
21
|
|
22
22
|
# @api private
|
23
|
-
UPLOAD_PART_OPTIONS =
|
24
|
-
|
23
|
+
UPLOAD_PART_OPTIONS = Set.new(
|
24
|
+
Client.api.operation(:upload_part).input.shape.member_names
|
25
|
+
)
|
25
26
|
|
26
27
|
# @option options [Client] :client
|
28
|
+
# @option options [Integer] :thread_count (THREAD_COUNT)
|
27
29
|
def initialize(options = {})
|
28
30
|
@client = options[:client] || Client.new
|
29
31
|
@thread_count = options[:thread_count] || THREAD_COUNT
|
@@ -32,9 +34,9 @@ module Aws
|
|
32
34
|
# @return [Client]
|
33
35
|
attr_reader :client
|
34
36
|
|
35
|
-
# @param [String,Pathname,File,Tempfile] source
|
36
|
-
# @option options [required,String] :bucket
|
37
|
-
# @option options [required,String] :key
|
37
|
+
# @param [String, Pathname, File, Tempfile] source The file to upload.
|
38
|
+
# @option options [required, String] :bucket The bucket to upload to.
|
39
|
+
# @option options [required, String] :key The key for the object.
|
38
40
|
# @return [void]
|
39
41
|
def upload(source, options = {})
|
40
42
|
if File.size(source) < MIN_PART_SIZE
|
@@ -57,7 +59,8 @@ module Aws
|
|
57
59
|
bucket: options[:bucket],
|
58
60
|
key: options[:key],
|
59
61
|
upload_id: upload_id,
|
60
|
-
multipart_upload: { parts: parts }
|
62
|
+
multipart_upload: { parts: parts }
|
63
|
+
)
|
61
64
|
end
|
62
65
|
|
63
66
|
def upload_parts(upload_id, source, options)
|
@@ -93,7 +96,7 @@ module Aws
|
|
93
96
|
part_number = 1
|
94
97
|
parts = []
|
95
98
|
while offset < size
|
96
|
-
parts << upload_part_opts(options).merge(
|
99
|
+
parts << upload_part_opts(options).merge(
|
97
100
|
upload_id: upload_id,
|
98
101
|
part_number: part_number,
|
99
102
|
body: FilePart.new(
|
@@ -101,7 +104,7 @@ module Aws
|
|
101
104
|
offset: offset,
|
102
105
|
size: part_size(size, default_part_size, offset)
|
103
106
|
)
|
104
|
-
|
107
|
+
)
|
105
108
|
part_number += 1
|
106
109
|
offset += default_part_size
|
107
110
|
end
|
@@ -70,7 +70,8 @@ module Aws::S3
|
|
70
70
|
data[:storage_class]
|
71
71
|
end
|
72
72
|
|
73
|
-
|
73
|
+
# Specifies the owner of the object that is part of the multipart
|
74
|
+
# upload.
|
74
75
|
# @return [Types::Owner]
|
75
76
|
def owner
|
76
77
|
data[:owner]
|
@@ -247,6 +248,7 @@ module Aws::S3
|
|
247
248
|
# })
|
248
249
|
# @param [Hash] options ({})
|
249
250
|
# @option options [Types::CompletedMultipartUpload] :multipart_upload
|
251
|
+
# The container for the multipart upload request information.
|
250
252
|
# @option options [String] :request_payer
|
251
253
|
# Confirms that the requester knows that she or he will be charged for
|
252
254
|
# the request. Bucket owners need not specify this parameter in their
|
@@ -298,7 +298,9 @@ module Aws::S3
|
|
298
298
|
# Size of the body in bytes. This parameter is useful when the size of
|
299
299
|
# the body cannot be determined automatically.
|
300
300
|
# @option options [String] :content_md5
|
301
|
-
# The base64-encoded 128-bit MD5 digest of the part data.
|
301
|
+
# The base64-encoded 128-bit MD5 digest of the part data. This parameter
|
302
|
+
# is auto-populated when using the command from the CLI. This parameted
|
303
|
+
# is required if object lock parameters are specified.
|
302
304
|
# @option options [String] :sse_customer_algorithm
|
303
305
|
# Specifies the algorithm to use to when encrypting the object (e.g.,
|
304
306
|
# AES256).
|