aws-sdk-s3 1.75.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 +7 -0
- data/lib/aws-sdk-s3.rb +73 -0
- data/lib/aws-sdk-s3/bucket.rb +861 -0
- data/lib/aws-sdk-s3/bucket_acl.rb +277 -0
- data/lib/aws-sdk-s3/bucket_cors.rb +262 -0
- data/lib/aws-sdk-s3/bucket_lifecycle.rb +264 -0
- data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +283 -0
- data/lib/aws-sdk-s3/bucket_logging.rb +251 -0
- data/lib/aws-sdk-s3/bucket_notification.rb +293 -0
- data/lib/aws-sdk-s3/bucket_policy.rb +242 -0
- data/lib/aws-sdk-s3/bucket_region_cache.rb +81 -0
- data/lib/aws-sdk-s3/bucket_request_payment.rb +236 -0
- data/lib/aws-sdk-s3/bucket_tagging.rb +251 -0
- data/lib/aws-sdk-s3/bucket_versioning.rb +312 -0
- data/lib/aws-sdk-s3/bucket_website.rb +292 -0
- data/lib/aws-sdk-s3/client.rb +11818 -0
- data/lib/aws-sdk-s3/client_api.rb +3014 -0
- data/lib/aws-sdk-s3/customizations.rb +34 -0
- data/lib/aws-sdk-s3/customizations/bucket.rb +162 -0
- data/lib/aws-sdk-s3/customizations/multipart_upload.rb +44 -0
- data/lib/aws-sdk-s3/customizations/object.rb +389 -0
- data/lib/aws-sdk-s3/customizations/object_summary.rb +85 -0
- data/lib/aws-sdk-s3/customizations/types/list_object_versions_output.rb +13 -0
- data/lib/aws-sdk-s3/encryption.rb +21 -0
- data/lib/aws-sdk-s3/encryption/client.rb +375 -0
- data/lib/aws-sdk-s3/encryption/decrypt_handler.rb +190 -0
- data/lib/aws-sdk-s3/encryption/default_cipher_provider.rb +65 -0
- data/lib/aws-sdk-s3/encryption/default_key_provider.rb +40 -0
- data/lib/aws-sdk-s3/encryption/encrypt_handler.rb +61 -0
- data/lib/aws-sdk-s3/encryption/errors.rb +15 -0
- data/lib/aws-sdk-s3/encryption/io_auth_decrypter.rb +58 -0
- data/lib/aws-sdk-s3/encryption/io_decrypter.rb +36 -0
- data/lib/aws-sdk-s3/encryption/io_encrypter.rb +71 -0
- data/lib/aws-sdk-s3/encryption/key_provider.rb +31 -0
- data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +75 -0
- data/lib/aws-sdk-s3/encryption/materials.rb +60 -0
- data/lib/aws-sdk-s3/encryption/utils.rb +81 -0
- data/lib/aws-sdk-s3/encryptionV2/client.rb +388 -0
- data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +198 -0
- data/lib/aws-sdk-s3/encryptionV2/default_cipher_provider.rb +103 -0
- data/lib/aws-sdk-s3/encryptionV2/default_key_provider.rb +38 -0
- data/lib/aws-sdk-s3/encryptionV2/encrypt_handler.rb +66 -0
- data/lib/aws-sdk-s3/encryptionV2/errors.rb +13 -0
- data/lib/aws-sdk-s3/encryptionV2/io_auth_decrypter.rb +56 -0
- data/lib/aws-sdk-s3/encryptionV2/io_decrypter.rb +35 -0
- data/lib/aws-sdk-s3/encryptionV2/io_encrypter.rb +71 -0
- data/lib/aws-sdk-s3/encryptionV2/key_provider.rb +29 -0
- data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +99 -0
- data/lib/aws-sdk-s3/encryptionV2/materials.rb +58 -0
- data/lib/aws-sdk-s3/encryptionV2/utils.rb +116 -0
- data/lib/aws-sdk-s3/encryption_v2.rb +20 -0
- data/lib/aws-sdk-s3/errors.rb +115 -0
- data/lib/aws-sdk-s3/event_streams.rb +69 -0
- data/lib/aws-sdk-s3/file_downloader.rb +142 -0
- data/lib/aws-sdk-s3/file_part.rb +78 -0
- data/lib/aws-sdk-s3/file_uploader.rb +70 -0
- data/lib/aws-sdk-s3/legacy_signer.rb +189 -0
- data/lib/aws-sdk-s3/multipart_file_uploader.rb +227 -0
- data/lib/aws-sdk-s3/multipart_stream_uploader.rb +173 -0
- data/lib/aws-sdk-s3/multipart_upload.rb +401 -0
- data/lib/aws-sdk-s3/multipart_upload_error.rb +18 -0
- data/lib/aws-sdk-s3/multipart_upload_part.rb +423 -0
- data/lib/aws-sdk-s3/object.rb +1422 -0
- data/lib/aws-sdk-s3/object_acl.rb +333 -0
- data/lib/aws-sdk-s3/object_copier.rb +101 -0
- data/lib/aws-sdk-s3/object_multipart_copier.rb +182 -0
- data/lib/aws-sdk-s3/object_summary.rb +1181 -0
- data/lib/aws-sdk-s3/object_version.rb +550 -0
- data/lib/aws-sdk-s3/plugins/accelerate.rb +87 -0
- data/lib/aws-sdk-s3/plugins/bucket_arn.rb +212 -0
- data/lib/aws-sdk-s3/plugins/bucket_dns.rb +91 -0
- data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +45 -0
- data/lib/aws-sdk-s3/plugins/dualstack.rb +74 -0
- data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +28 -0
- data/lib/aws-sdk-s3/plugins/get_bucket_location_fix.rb +25 -0
- data/lib/aws-sdk-s3/plugins/http_200_errors.rb +55 -0
- data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +62 -0
- data/lib/aws-sdk-s3/plugins/location_constraint.rb +35 -0
- data/lib/aws-sdk-s3/plugins/md5s.rb +84 -0
- data/lib/aws-sdk-s3/plugins/redirects.rb +45 -0
- data/lib/aws-sdk-s3/plugins/s3_host_id.rb +30 -0
- data/lib/aws-sdk-s3/plugins/s3_signer.rb +222 -0
- data/lib/aws-sdk-s3/plugins/sse_cpk.rb +70 -0
- data/lib/aws-sdk-s3/plugins/streaming_retry.rb +118 -0
- data/lib/aws-sdk-s3/plugins/url_encoded_keys.rb +97 -0
- data/lib/aws-sdk-s3/presigned_post.rb +686 -0
- data/lib/aws-sdk-s3/presigner.rb +253 -0
- data/lib/aws-sdk-s3/resource.rb +117 -0
- data/lib/aws-sdk-s3/types.rb +13154 -0
- data/lib/aws-sdk-s3/waiters.rb +243 -0
- metadata +184 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Aws
|
|
4
|
+
module S3
|
|
5
|
+
class MultipartUploadError < StandardError
|
|
6
|
+
|
|
7
|
+
def initialize(message, errors)
|
|
8
|
+
@errors = errors
|
|
9
|
+
super(message)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# @return [Array<StandardError>] The list of errors encountered
|
|
13
|
+
# when uploading or aborting the upload.
|
|
14
|
+
attr_reader :errors
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# WARNING ABOUT GENERATED CODE
|
|
4
|
+
#
|
|
5
|
+
# This file is generated. See the contributing guide for more information:
|
|
6
|
+
# https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
|
|
7
|
+
#
|
|
8
|
+
# WARNING ABOUT GENERATED CODE
|
|
9
|
+
|
|
10
|
+
module Aws::S3
|
|
11
|
+
|
|
12
|
+
class MultipartUploadPart
|
|
13
|
+
|
|
14
|
+
extend Aws::Deprecations
|
|
15
|
+
|
|
16
|
+
# @overload def initialize(bucket_name, object_key, multipart_upload_id, part_number, options = {})
|
|
17
|
+
# @param [String] bucket_name
|
|
18
|
+
# @param [String] object_key
|
|
19
|
+
# @param [String] multipart_upload_id
|
|
20
|
+
# @param [Integer] part_number
|
|
21
|
+
# @option options [Client] :client
|
|
22
|
+
# @overload def initialize(options = {})
|
|
23
|
+
# @option options [required, String] :bucket_name
|
|
24
|
+
# @option options [required, String] :object_key
|
|
25
|
+
# @option options [required, String] :multipart_upload_id
|
|
26
|
+
# @option options [required, Integer] :part_number
|
|
27
|
+
# @option options [Client] :client
|
|
28
|
+
def initialize(*args)
|
|
29
|
+
options = Hash === args.last ? args.pop.dup : {}
|
|
30
|
+
@bucket_name = extract_bucket_name(args, options)
|
|
31
|
+
@object_key = extract_object_key(args, options)
|
|
32
|
+
@multipart_upload_id = extract_multipart_upload_id(args, options)
|
|
33
|
+
@part_number = extract_part_number(args, options)
|
|
34
|
+
@data = options.delete(:data)
|
|
35
|
+
@client = options.delete(:client) || Client.new(options)
|
|
36
|
+
@waiter_block_warned = false
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# @!group Read-Only Attributes
|
|
40
|
+
|
|
41
|
+
# @return [String]
|
|
42
|
+
def bucket_name
|
|
43
|
+
@bucket_name
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @return [String]
|
|
47
|
+
def object_key
|
|
48
|
+
@object_key
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# @return [String]
|
|
52
|
+
def multipart_upload_id
|
|
53
|
+
@multipart_upload_id
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# @return [Integer]
|
|
57
|
+
def part_number
|
|
58
|
+
@part_number
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Date and time at which the part was uploaded.
|
|
62
|
+
# @return [Time]
|
|
63
|
+
def last_modified
|
|
64
|
+
data[:last_modified]
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Entity tag returned when the part was uploaded.
|
|
68
|
+
# @return [String]
|
|
69
|
+
def etag
|
|
70
|
+
data[:etag]
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Size in bytes of the uploaded part data.
|
|
74
|
+
# @return [Integer]
|
|
75
|
+
def size
|
|
76
|
+
data[:size]
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# @!endgroup
|
|
80
|
+
|
|
81
|
+
# @return [Client]
|
|
82
|
+
def client
|
|
83
|
+
@client
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# @raise [NotImplementedError]
|
|
87
|
+
# @api private
|
|
88
|
+
def load
|
|
89
|
+
msg = "#load is not implemented, data only available via enumeration"
|
|
90
|
+
raise NotImplementedError, msg
|
|
91
|
+
end
|
|
92
|
+
alias :reload :load
|
|
93
|
+
|
|
94
|
+
# @raise [NotImplementedError] Raises when {#data_loaded?} is `false`.
|
|
95
|
+
# @return [Types::Part]
|
|
96
|
+
# Returns the data for this {MultipartUploadPart}.
|
|
97
|
+
def data
|
|
98
|
+
load unless @data
|
|
99
|
+
@data
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# @return [Boolean]
|
|
103
|
+
# Returns `true` if this resource is loaded. Accessing attributes or
|
|
104
|
+
# {#data} on an unloaded resource will trigger a call to {#load}.
|
|
105
|
+
def data_loaded?
|
|
106
|
+
!!@data
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# @deprecated Use [Aws::S3::Client] #wait_until instead
|
|
110
|
+
#
|
|
111
|
+
# Waiter polls an API operation until a resource enters a desired
|
|
112
|
+
# state.
|
|
113
|
+
#
|
|
114
|
+
# @note The waiting operation is performed on a copy. The original resource
|
|
115
|
+
# remains unchanged.
|
|
116
|
+
#
|
|
117
|
+
# ## Basic Usage
|
|
118
|
+
#
|
|
119
|
+
# Waiter will polls until it is successful, it fails by
|
|
120
|
+
# entering a terminal state, or until a maximum number of attempts
|
|
121
|
+
# are made.
|
|
122
|
+
#
|
|
123
|
+
# # polls in a loop until condition is true
|
|
124
|
+
# resource.wait_until(options) {|resource| condition}
|
|
125
|
+
#
|
|
126
|
+
# ## Example
|
|
127
|
+
#
|
|
128
|
+
# instance.wait_until(max_attempts:10, delay:5) do |instance|
|
|
129
|
+
# instance.state.name == 'running'
|
|
130
|
+
# end
|
|
131
|
+
#
|
|
132
|
+
# ## Configuration
|
|
133
|
+
#
|
|
134
|
+
# You can configure the maximum number of polling attempts, and the
|
|
135
|
+
# delay (in seconds) between each polling attempt. The waiting condition is
|
|
136
|
+
# set by passing a block to {#wait_until}:
|
|
137
|
+
#
|
|
138
|
+
# # poll for ~25 seconds
|
|
139
|
+
# resource.wait_until(max_attempts:5,delay:5) {|resource|...}
|
|
140
|
+
#
|
|
141
|
+
# ## Callbacks
|
|
142
|
+
#
|
|
143
|
+
# You can be notified before each polling attempt and before each
|
|
144
|
+
# delay. If you throw `:success` or `:failure` from these callbacks,
|
|
145
|
+
# it will terminate the waiter.
|
|
146
|
+
#
|
|
147
|
+
# started_at = Time.now
|
|
148
|
+
# # poll for 1 hour, instead of a number of attempts
|
|
149
|
+
# proc = Proc.new do |attempts, response|
|
|
150
|
+
# throw :failure if Time.now - started_at > 3600
|
|
151
|
+
# end
|
|
152
|
+
#
|
|
153
|
+
# # disable max attempts
|
|
154
|
+
# instance.wait_until(before_wait:proc, max_attempts:nil) {...}
|
|
155
|
+
#
|
|
156
|
+
# ## Handling Errors
|
|
157
|
+
#
|
|
158
|
+
# When a waiter is successful, it returns the Resource. When a waiter
|
|
159
|
+
# fails, it raises an error.
|
|
160
|
+
#
|
|
161
|
+
# begin
|
|
162
|
+
# resource.wait_until(...)
|
|
163
|
+
# rescue Aws::Waiters::Errors::WaiterFailed
|
|
164
|
+
# # resource did not enter the desired state in time
|
|
165
|
+
# end
|
|
166
|
+
#
|
|
167
|
+
# @yieldparam [Resource] resource to be used in the waiting condition.
|
|
168
|
+
#
|
|
169
|
+
# @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter
|
|
170
|
+
# terminates because the waiter has entered a state that it will not
|
|
171
|
+
# transition out of, preventing success.
|
|
172
|
+
#
|
|
173
|
+
# yet successful.
|
|
174
|
+
#
|
|
175
|
+
# @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is
|
|
176
|
+
# encountered while polling for a resource that is not expected.
|
|
177
|
+
#
|
|
178
|
+
# @raise [NotImplementedError] Raised when the resource does not
|
|
179
|
+
#
|
|
180
|
+
# @option options [Integer] :max_attempts (10) Maximum number of
|
|
181
|
+
# attempts
|
|
182
|
+
# @option options [Integer] :delay (10) Delay between each
|
|
183
|
+
# attempt in seconds
|
|
184
|
+
# @option options [Proc] :before_attempt (nil) Callback
|
|
185
|
+
# invoked before each attempt
|
|
186
|
+
# @option options [Proc] :before_wait (nil) Callback
|
|
187
|
+
# invoked before each wait
|
|
188
|
+
# @return [Resource] if the waiter was successful
|
|
189
|
+
def wait_until(options = {}, &block)
|
|
190
|
+
self_copy = self.dup
|
|
191
|
+
attempts = 0
|
|
192
|
+
options[:max_attempts] = 10 unless options.key?(:max_attempts)
|
|
193
|
+
options[:delay] ||= 10
|
|
194
|
+
options[:poller] = Proc.new do
|
|
195
|
+
attempts += 1
|
|
196
|
+
if block.call(self_copy)
|
|
197
|
+
[:success, self_copy]
|
|
198
|
+
else
|
|
199
|
+
self_copy.reload unless attempts == options[:max_attempts]
|
|
200
|
+
:retry
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
Aws::Waiters::Waiter.new(options).wait({})
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# @!group Actions
|
|
207
|
+
|
|
208
|
+
# @example Request syntax with placeholder values
|
|
209
|
+
#
|
|
210
|
+
# multipart_upload_part.copy_from({
|
|
211
|
+
# copy_source: "CopySource", # required
|
|
212
|
+
# copy_source_if_match: "CopySourceIfMatch",
|
|
213
|
+
# copy_source_if_modified_since: Time.now,
|
|
214
|
+
# copy_source_if_none_match: "CopySourceIfNoneMatch",
|
|
215
|
+
# copy_source_if_unmodified_since: Time.now,
|
|
216
|
+
# copy_source_range: "CopySourceRange",
|
|
217
|
+
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
|
218
|
+
# sse_customer_key: "SSECustomerKey",
|
|
219
|
+
# sse_customer_key_md5: "SSECustomerKeyMD5",
|
|
220
|
+
# copy_source_sse_customer_algorithm: "CopySourceSSECustomerAlgorithm",
|
|
221
|
+
# copy_source_sse_customer_key: "CopySourceSSECustomerKey",
|
|
222
|
+
# copy_source_sse_customer_key_md5: "CopySourceSSECustomerKeyMD5",
|
|
223
|
+
# request_payer: "requester", # accepts requester
|
|
224
|
+
# })
|
|
225
|
+
# @param [Hash] options ({})
|
|
226
|
+
# @option options [required, String] :copy_source
|
|
227
|
+
# The name of the source bucket and key name of the source object,
|
|
228
|
+
# separated by a slash (/). Must be URL-encoded.
|
|
229
|
+
# @option options [String] :copy_source_if_match
|
|
230
|
+
# Copies the object if its entity tag (ETag) matches the specified tag.
|
|
231
|
+
# @option options [Time,DateTime,Date,Integer,String] :copy_source_if_modified_since
|
|
232
|
+
# Copies the object if it has been modified since the specified time.
|
|
233
|
+
# @option options [String] :copy_source_if_none_match
|
|
234
|
+
# Copies the object if its entity tag (ETag) is different than the
|
|
235
|
+
# specified ETag.
|
|
236
|
+
# @option options [Time,DateTime,Date,Integer,String] :copy_source_if_unmodified_since
|
|
237
|
+
# Copies the object if it hasn't been modified since the specified
|
|
238
|
+
# time.
|
|
239
|
+
# @option options [String] :copy_source_range
|
|
240
|
+
# The range of bytes to copy from the source object. The range value
|
|
241
|
+
# must use the form bytes=first-last, where the first and last are the
|
|
242
|
+
# zero-based byte offsets to copy. For example, bytes=0-9 indicates that
|
|
243
|
+
# you want to copy the first 10 bytes of the source. You can copy a
|
|
244
|
+
# range only if the source object is greater than 5 MB.
|
|
245
|
+
# @option options [String] :sse_customer_algorithm
|
|
246
|
+
# Specifies the algorithm to use to when encrypting the object (for
|
|
247
|
+
# example, AES256).
|
|
248
|
+
# @option options [String] :sse_customer_key
|
|
249
|
+
# Specifies the customer-provided encryption key for Amazon S3 to use in
|
|
250
|
+
# encrypting data. This value is used to store the object and then it is
|
|
251
|
+
# discarded; Amazon S3 does not store the encryption key. The key must
|
|
252
|
+
# be appropriate for use with the algorithm specified in the
|
|
253
|
+
# `x-amz-server-side-encryption-customer-algorithm` header. This must
|
|
254
|
+
# be the same encryption key specified in the initiate multipart upload
|
|
255
|
+
# request.
|
|
256
|
+
# @option options [String] :sse_customer_key_md5
|
|
257
|
+
# Specifies the 128-bit MD5 digest of the encryption key according to
|
|
258
|
+
# RFC 1321. Amazon S3 uses this header for a message integrity check to
|
|
259
|
+
# ensure that the encryption key was transmitted without error.
|
|
260
|
+
# @option options [String] :copy_source_sse_customer_algorithm
|
|
261
|
+
# Specifies the algorithm to use when decrypting the source object (for
|
|
262
|
+
# example, AES256).
|
|
263
|
+
# @option options [String] :copy_source_sse_customer_key
|
|
264
|
+
# Specifies the customer-provided encryption key for Amazon S3 to use to
|
|
265
|
+
# decrypt the source object. The encryption key provided in this header
|
|
266
|
+
# must be one that was used when the source object was created.
|
|
267
|
+
# @option options [String] :copy_source_sse_customer_key_md5
|
|
268
|
+
# Specifies the 128-bit MD5 digest of the encryption key according to
|
|
269
|
+
# RFC 1321. Amazon S3 uses this header for a message integrity check to
|
|
270
|
+
# ensure that the encryption key was transmitted without error.
|
|
271
|
+
# @option options [String] :request_payer
|
|
272
|
+
# Confirms that the requester knows that they will be charged for the
|
|
273
|
+
# request. Bucket owners need not specify this parameter in their
|
|
274
|
+
# requests. For information about downloading objects from requester
|
|
275
|
+
# pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
|
|
276
|
+
# in the *Amazon S3 Developer Guide*.
|
|
277
|
+
#
|
|
278
|
+
#
|
|
279
|
+
#
|
|
280
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
|
281
|
+
# @return [Types::UploadPartCopyOutput]
|
|
282
|
+
def copy_from(options = {})
|
|
283
|
+
options = options.merge(
|
|
284
|
+
bucket: @bucket_name,
|
|
285
|
+
key: @object_key,
|
|
286
|
+
upload_id: @multipart_upload_id,
|
|
287
|
+
part_number: @part_number
|
|
288
|
+
)
|
|
289
|
+
resp = @client.upload_part_copy(options)
|
|
290
|
+
resp.data
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
# @example Request syntax with placeholder values
|
|
294
|
+
#
|
|
295
|
+
# multipart_upload_part.upload({
|
|
296
|
+
# body: source_file,
|
|
297
|
+
# content_length: 1,
|
|
298
|
+
# content_md5: "ContentMD5",
|
|
299
|
+
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
|
300
|
+
# sse_customer_key: "SSECustomerKey",
|
|
301
|
+
# sse_customer_key_md5: "SSECustomerKeyMD5",
|
|
302
|
+
# request_payer: "requester", # accepts requester
|
|
303
|
+
# })
|
|
304
|
+
# @param [Hash] options ({})
|
|
305
|
+
# @option options [String, IO] :body
|
|
306
|
+
# Object data.
|
|
307
|
+
# @option options [Integer] :content_length
|
|
308
|
+
# Size of the body in bytes. This parameter is useful when the size of
|
|
309
|
+
# the body cannot be determined automatically.
|
|
310
|
+
# @option options [String] :content_md5
|
|
311
|
+
# The base64-encoded 128-bit MD5 digest of the part data. This parameter
|
|
312
|
+
# is auto-populated when using the command from the CLI. This parameter
|
|
313
|
+
# is required if object lock parameters are specified.
|
|
314
|
+
# @option options [String] :sse_customer_algorithm
|
|
315
|
+
# Specifies the algorithm to use to when encrypting the object (for
|
|
316
|
+
# example, AES256).
|
|
317
|
+
# @option options [String] :sse_customer_key
|
|
318
|
+
# Specifies the customer-provided encryption key for Amazon S3 to use in
|
|
319
|
+
# encrypting data. This value is used to store the object and then it is
|
|
320
|
+
# discarded; Amazon S3 does not store the encryption key. The key must
|
|
321
|
+
# be appropriate for use with the algorithm specified in the
|
|
322
|
+
# `x-amz-server-side-encryption-customer-algorithm header`. This must
|
|
323
|
+
# be the same encryption key specified in the initiate multipart upload
|
|
324
|
+
# request.
|
|
325
|
+
# @option options [String] :sse_customer_key_md5
|
|
326
|
+
# Specifies the 128-bit MD5 digest of the encryption key according to
|
|
327
|
+
# RFC 1321. Amazon S3 uses this header for a message integrity check to
|
|
328
|
+
# ensure that the encryption key was transmitted without error.
|
|
329
|
+
# @option options [String] :request_payer
|
|
330
|
+
# Confirms that the requester knows that they will be charged for the
|
|
331
|
+
# request. Bucket owners need not specify this parameter in their
|
|
332
|
+
# requests. For information about downloading objects from requester
|
|
333
|
+
# pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
|
|
334
|
+
# in the *Amazon S3 Developer Guide*.
|
|
335
|
+
#
|
|
336
|
+
#
|
|
337
|
+
#
|
|
338
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
|
339
|
+
# @return [Types::UploadPartOutput]
|
|
340
|
+
def upload(options = {})
|
|
341
|
+
options = options.merge(
|
|
342
|
+
bucket: @bucket_name,
|
|
343
|
+
key: @object_key,
|
|
344
|
+
upload_id: @multipart_upload_id,
|
|
345
|
+
part_number: @part_number
|
|
346
|
+
)
|
|
347
|
+
resp = @client.upload_part(options)
|
|
348
|
+
resp.data
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
# @!group Associations
|
|
352
|
+
|
|
353
|
+
# @return [MultipartUpload]
|
|
354
|
+
def multipart_upload
|
|
355
|
+
MultipartUpload.new(
|
|
356
|
+
bucket_name: @bucket_name,
|
|
357
|
+
object_key: @object_key,
|
|
358
|
+
id: @multipart_upload_id,
|
|
359
|
+
client: @client
|
|
360
|
+
)
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
# @deprecated
|
|
364
|
+
# @api private
|
|
365
|
+
def identifiers
|
|
366
|
+
{
|
|
367
|
+
bucket_name: @bucket_name,
|
|
368
|
+
object_key: @object_key,
|
|
369
|
+
multipart_upload_id: @multipart_upload_id,
|
|
370
|
+
part_number: @part_number
|
|
371
|
+
}
|
|
372
|
+
end
|
|
373
|
+
deprecated(:identifiers)
|
|
374
|
+
|
|
375
|
+
private
|
|
376
|
+
|
|
377
|
+
def extract_bucket_name(args, options)
|
|
378
|
+
value = args[0] || options.delete(:bucket_name)
|
|
379
|
+
case value
|
|
380
|
+
when String then value
|
|
381
|
+
when nil then raise ArgumentError, "missing required option :bucket_name"
|
|
382
|
+
else
|
|
383
|
+
msg = "expected :bucket_name to be a String, got #{value.class}"
|
|
384
|
+
raise ArgumentError, msg
|
|
385
|
+
end
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
def extract_object_key(args, options)
|
|
389
|
+
value = args[1] || options.delete(:object_key)
|
|
390
|
+
case value
|
|
391
|
+
when String then value
|
|
392
|
+
when nil then raise ArgumentError, "missing required option :object_key"
|
|
393
|
+
else
|
|
394
|
+
msg = "expected :object_key to be a String, got #{value.class}"
|
|
395
|
+
raise ArgumentError, msg
|
|
396
|
+
end
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
def extract_multipart_upload_id(args, options)
|
|
400
|
+
value = args[2] || options.delete(:multipart_upload_id)
|
|
401
|
+
case value
|
|
402
|
+
when String then value
|
|
403
|
+
when nil then raise ArgumentError, "missing required option :multipart_upload_id"
|
|
404
|
+
else
|
|
405
|
+
msg = "expected :multipart_upload_id to be a String, got #{value.class}"
|
|
406
|
+
raise ArgumentError, msg
|
|
407
|
+
end
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
def extract_part_number(args, options)
|
|
411
|
+
value = args[3] || options.delete(:part_number)
|
|
412
|
+
case value
|
|
413
|
+
when Integer then value
|
|
414
|
+
when nil then raise ArgumentError, "missing required option :part_number"
|
|
415
|
+
else
|
|
416
|
+
msg = "expected :part_number to be a Integer, got #{value.class}"
|
|
417
|
+
raise ArgumentError, msg
|
|
418
|
+
end
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
class Collection < Aws::Resources::Collection; end
|
|
422
|
+
end
|
|
423
|
+
end
|
|
@@ -0,0 +1,1422 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# WARNING ABOUT GENERATED CODE
|
|
4
|
+
#
|
|
5
|
+
# This file is generated. See the contributing guide for more information:
|
|
6
|
+
# https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
|
|
7
|
+
#
|
|
8
|
+
# WARNING ABOUT GENERATED CODE
|
|
9
|
+
|
|
10
|
+
module Aws::S3
|
|
11
|
+
|
|
12
|
+
class Object
|
|
13
|
+
|
|
14
|
+
extend Aws::Deprecations
|
|
15
|
+
|
|
16
|
+
# @overload def initialize(bucket_name, key, options = {})
|
|
17
|
+
# @param [String] bucket_name
|
|
18
|
+
# @param [String] key
|
|
19
|
+
# @option options [Client] :client
|
|
20
|
+
# @overload def initialize(options = {})
|
|
21
|
+
# @option options [required, String] :bucket_name
|
|
22
|
+
# @option options [required, String] :key
|
|
23
|
+
# @option options [Client] :client
|
|
24
|
+
def initialize(*args)
|
|
25
|
+
options = Hash === args.last ? args.pop.dup : {}
|
|
26
|
+
@bucket_name = extract_bucket_name(args, options)
|
|
27
|
+
@key = extract_key(args, options)
|
|
28
|
+
@data = options.delete(:data)
|
|
29
|
+
@client = options.delete(:client) || Client.new(options)
|
|
30
|
+
@waiter_block_warned = false
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @!group Read-Only Attributes
|
|
34
|
+
|
|
35
|
+
# @return [String]
|
|
36
|
+
def bucket_name
|
|
37
|
+
@bucket_name
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @return [String]
|
|
41
|
+
def key
|
|
42
|
+
@key
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Specifies whether the object retrieved was (true) or was not (false) a
|
|
46
|
+
# Delete Marker. If false, this response header does not appear in the
|
|
47
|
+
# response.
|
|
48
|
+
# @return [Boolean]
|
|
49
|
+
def delete_marker
|
|
50
|
+
data[:delete_marker]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Indicates that a range of bytes was specified.
|
|
54
|
+
# @return [String]
|
|
55
|
+
def accept_ranges
|
|
56
|
+
data[:accept_ranges]
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# If the object expiration is configured (see PUT Bucket lifecycle), the
|
|
60
|
+
# response includes this header. It includes the expiry-date and rule-id
|
|
61
|
+
# key-value pairs providing object expiration information. The value of
|
|
62
|
+
# the rule-id is URL encoded.
|
|
63
|
+
# @return [String]
|
|
64
|
+
def expiration
|
|
65
|
+
data[:expiration]
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# If the object is an archived object (an object whose storage class is
|
|
69
|
+
# GLACIER), the response includes this header if either the archive
|
|
70
|
+
# restoration is in progress (see RestoreObject or an archive copy is
|
|
71
|
+
# already restored.
|
|
72
|
+
#
|
|
73
|
+
# If an archive copy is already restored, the header value indicates
|
|
74
|
+
# when Amazon S3 is scheduled to delete the object copy. For example:
|
|
75
|
+
#
|
|
76
|
+
# `x-amz-restore: ongoing-request="false", expiry-date="Fri, 23 Dec 2012
|
|
77
|
+
# 00:00:00 GMT"`
|
|
78
|
+
#
|
|
79
|
+
# If the object restoration is in progress, the header returns the value
|
|
80
|
+
# `ongoing-request="true"`.
|
|
81
|
+
#
|
|
82
|
+
# For more information about archiving objects, see [Transitioning
|
|
83
|
+
# Objects: General Considerations][1].
|
|
84
|
+
#
|
|
85
|
+
#
|
|
86
|
+
#
|
|
87
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html#lifecycle-transition-general-considerations
|
|
88
|
+
# @return [String]
|
|
89
|
+
def restore
|
|
90
|
+
data[:restore]
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Last modified date of the object
|
|
94
|
+
# @return [Time]
|
|
95
|
+
def last_modified
|
|
96
|
+
data[:last_modified]
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Size of the body in bytes.
|
|
100
|
+
# @return [Integer]
|
|
101
|
+
def content_length
|
|
102
|
+
data[:content_length]
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# An ETag is an opaque identifier assigned by a web server to a specific
|
|
106
|
+
# version of a resource found at a URL.
|
|
107
|
+
# @return [String]
|
|
108
|
+
def etag
|
|
109
|
+
data[:etag]
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# This is set to the number of metadata entries not returned in
|
|
113
|
+
# `x-amz-meta` headers. This can happen if you create metadata using an
|
|
114
|
+
# API like SOAP that supports more flexible metadata than the REST API.
|
|
115
|
+
# For example, using SOAP, you can create metadata whose values are not
|
|
116
|
+
# legal HTTP headers.
|
|
117
|
+
# @return [Integer]
|
|
118
|
+
def missing_meta
|
|
119
|
+
data[:missing_meta]
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Version of the object.
|
|
123
|
+
# @return [String]
|
|
124
|
+
def version_id
|
|
125
|
+
data[:version_id]
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Specifies caching behavior along the request/reply chain.
|
|
129
|
+
# @return [String]
|
|
130
|
+
def cache_control
|
|
131
|
+
data[:cache_control]
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Specifies presentational information for the object.
|
|
135
|
+
# @return [String]
|
|
136
|
+
def content_disposition
|
|
137
|
+
data[:content_disposition]
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Specifies what content encodings have been applied to the object and
|
|
141
|
+
# thus what decoding mechanisms must be applied to obtain the media-type
|
|
142
|
+
# referenced by the Content-Type header field.
|
|
143
|
+
# @return [String]
|
|
144
|
+
def content_encoding
|
|
145
|
+
data[:content_encoding]
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# The language the content is in.
|
|
149
|
+
# @return [String]
|
|
150
|
+
def content_language
|
|
151
|
+
data[:content_language]
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# A standard MIME type describing the format of the object data.
|
|
155
|
+
# @return [String]
|
|
156
|
+
def content_type
|
|
157
|
+
data[:content_type]
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# The date and time at which the object is no longer cacheable.
|
|
161
|
+
# @return [Time]
|
|
162
|
+
def expires
|
|
163
|
+
data[:expires]
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# @return [String]
|
|
167
|
+
def expires_string
|
|
168
|
+
data[:expires_string]
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# If the bucket is configured as a website, redirects requests for this
|
|
172
|
+
# object to another object in the same bucket or to an external URL.
|
|
173
|
+
# Amazon S3 stores the value of this header in the object metadata.
|
|
174
|
+
# @return [String]
|
|
175
|
+
def website_redirect_location
|
|
176
|
+
data[:website_redirect_location]
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# If the object is stored using server-side encryption either with an
|
|
180
|
+
# AWS KMS customer master key (CMK) or an Amazon S3-managed encryption
|
|
181
|
+
# key, the response includes this header with the value of the
|
|
182
|
+
# server-side encryption algorithm used when storing this object in
|
|
183
|
+
# Amazon S3 (for example, AES256, aws:kms).
|
|
184
|
+
# @return [String]
|
|
185
|
+
def server_side_encryption
|
|
186
|
+
data[:server_side_encryption]
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# A map of metadata to store with the object in S3.
|
|
190
|
+
# @return [Hash<String,String>]
|
|
191
|
+
def metadata
|
|
192
|
+
data[:metadata]
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# If server-side encryption with a customer-provided encryption key was
|
|
196
|
+
# requested, the response will include this header confirming the
|
|
197
|
+
# encryption algorithm used.
|
|
198
|
+
# @return [String]
|
|
199
|
+
def sse_customer_algorithm
|
|
200
|
+
data[:sse_customer_algorithm]
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# If server-side encryption with a customer-provided encryption key was
|
|
204
|
+
# requested, the response will include this header to provide round-trip
|
|
205
|
+
# message integrity verification of the customer-provided encryption
|
|
206
|
+
# key.
|
|
207
|
+
# @return [String]
|
|
208
|
+
def sse_customer_key_md5
|
|
209
|
+
data[:sse_customer_key_md5]
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# If present, specifies the ID of the AWS Key Management Service (AWS
|
|
213
|
+
# KMS) symmetric customer managed customer master key (CMK) that was
|
|
214
|
+
# used for the object.
|
|
215
|
+
# @return [String]
|
|
216
|
+
def ssekms_key_id
|
|
217
|
+
data[:ssekms_key_id]
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Provides storage class information of the object. Amazon S3 returns
|
|
221
|
+
# this header for all objects except for S3 Standard storage class
|
|
222
|
+
# objects.
|
|
223
|
+
#
|
|
224
|
+
# For more information, see [Storage Classes][1].
|
|
225
|
+
#
|
|
226
|
+
#
|
|
227
|
+
#
|
|
228
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html
|
|
229
|
+
# @return [String]
|
|
230
|
+
def storage_class
|
|
231
|
+
data[:storage_class]
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
# If present, indicates that the requester was successfully charged for
|
|
235
|
+
# the request.
|
|
236
|
+
# @return [String]
|
|
237
|
+
def request_charged
|
|
238
|
+
data[:request_charged]
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# Amazon S3 can return this header if your request involves a bucket
|
|
242
|
+
# that is either a source or destination in a replication rule.
|
|
243
|
+
#
|
|
244
|
+
# In replication, you have a source bucket on which you configure
|
|
245
|
+
# replication and destination bucket where Amazon S3 stores object
|
|
246
|
+
# replicas. When you request an object (`GetObject`) or object metadata
|
|
247
|
+
# (`HeadObject`) from these buckets, Amazon S3 will return the
|
|
248
|
+
# `x-amz-replication-status` header in the response as follows:
|
|
249
|
+
#
|
|
250
|
+
# * If requesting an object from the source bucket — Amazon S3 will
|
|
251
|
+
# return the `x-amz-replication-status` header if the object in your
|
|
252
|
+
# request is eligible for replication.
|
|
253
|
+
#
|
|
254
|
+
# For example, suppose that in your replication configuration, you
|
|
255
|
+
# specify object prefix `TaxDocs` requesting Amazon S3 to replicate
|
|
256
|
+
# objects with key prefix `TaxDocs`. Any objects you upload with this
|
|
257
|
+
# key name prefix, for example `TaxDocs/document1.pdf`, are eligible
|
|
258
|
+
# for replication. For any object request with this key name prefix,
|
|
259
|
+
# Amazon S3 will return the `x-amz-replication-status` header with
|
|
260
|
+
# value PENDING, COMPLETED or FAILED indicating object replication
|
|
261
|
+
# status.
|
|
262
|
+
#
|
|
263
|
+
# * If requesting an object from the destination bucket — Amazon S3 will
|
|
264
|
+
# return the `x-amz-replication-status` header with value REPLICA if
|
|
265
|
+
# the object in your request is a replica that Amazon S3 created.
|
|
266
|
+
#
|
|
267
|
+
# For more information, see [Replication][1].
|
|
268
|
+
#
|
|
269
|
+
#
|
|
270
|
+
#
|
|
271
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html
|
|
272
|
+
# @return [String]
|
|
273
|
+
def replication_status
|
|
274
|
+
data[:replication_status]
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
# The count of parts this object has.
|
|
278
|
+
# @return [Integer]
|
|
279
|
+
def parts_count
|
|
280
|
+
data[:parts_count]
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
# The Object Lock mode, if any, that's in effect for this object. This
|
|
284
|
+
# header is only returned if the requester has the
|
|
285
|
+
# `s3:GetObjectRetention` permission. For more information about S3
|
|
286
|
+
# Object Lock, see [Object Lock][1].
|
|
287
|
+
#
|
|
288
|
+
#
|
|
289
|
+
#
|
|
290
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lock.html
|
|
291
|
+
# @return [String]
|
|
292
|
+
def object_lock_mode
|
|
293
|
+
data[:object_lock_mode]
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
# The date and time when the Object Lock retention period expires. This
|
|
297
|
+
# header is only returned if the requester has the
|
|
298
|
+
# `s3:GetObjectRetention` permission.
|
|
299
|
+
# @return [Time]
|
|
300
|
+
def object_lock_retain_until_date
|
|
301
|
+
data[:object_lock_retain_until_date]
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
# Specifies whether a legal hold is in effect for this object. This
|
|
305
|
+
# header is only returned if the requester has the
|
|
306
|
+
# `s3:GetObjectLegalHold` permission. This header is not returned if the
|
|
307
|
+
# specified version of this object has never had a legal hold applied.
|
|
308
|
+
# For more information about S3 Object Lock, see [Object Lock][1].
|
|
309
|
+
#
|
|
310
|
+
#
|
|
311
|
+
#
|
|
312
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lock.html
|
|
313
|
+
# @return [String]
|
|
314
|
+
def object_lock_legal_hold_status
|
|
315
|
+
data[:object_lock_legal_hold_status]
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
# @!endgroup
|
|
319
|
+
|
|
320
|
+
# @return [Client]
|
|
321
|
+
def client
|
|
322
|
+
@client
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
# Loads, or reloads {#data} for the current {Object}.
|
|
326
|
+
# Returns `self` making it possible to chain methods.
|
|
327
|
+
#
|
|
328
|
+
# object.reload.data
|
|
329
|
+
#
|
|
330
|
+
# @return [self]
|
|
331
|
+
def load
|
|
332
|
+
resp = @client.head_object(
|
|
333
|
+
bucket: @bucket_name,
|
|
334
|
+
key: @key
|
|
335
|
+
)
|
|
336
|
+
@data = resp.data
|
|
337
|
+
self
|
|
338
|
+
end
|
|
339
|
+
alias :reload :load
|
|
340
|
+
|
|
341
|
+
# @return [Types::HeadObjectOutput]
|
|
342
|
+
# Returns the data for this {Object}. Calls
|
|
343
|
+
# {Client#head_object} if {#data_loaded?} is `false`.
|
|
344
|
+
def data
|
|
345
|
+
load unless @data
|
|
346
|
+
@data
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
# @return [Boolean]
|
|
350
|
+
# Returns `true` if this resource is loaded. Accessing attributes or
|
|
351
|
+
# {#data} on an unloaded resource will trigger a call to {#load}.
|
|
352
|
+
def data_loaded?
|
|
353
|
+
!!@data
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
# @param [Hash] options ({})
|
|
357
|
+
# @return [Boolean]
|
|
358
|
+
# Returns `true` if the Object exists.
|
|
359
|
+
def exists?(options = {})
|
|
360
|
+
begin
|
|
361
|
+
wait_until_exists(options.merge(max_attempts: 1))
|
|
362
|
+
true
|
|
363
|
+
rescue Aws::Waiters::Errors::UnexpectedError => e
|
|
364
|
+
raise e.error
|
|
365
|
+
rescue Aws::Waiters::Errors::WaiterFailed
|
|
366
|
+
false
|
|
367
|
+
end
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
# @param [Hash] options ({})
|
|
371
|
+
# @option options [Integer] :max_attempts (20)
|
|
372
|
+
# @option options [Float] :delay (5)
|
|
373
|
+
# @option options [Proc] :before_attempt
|
|
374
|
+
# @option options [Proc] :before_wait
|
|
375
|
+
# @return [Object]
|
|
376
|
+
def wait_until_exists(options = {}, &block)
|
|
377
|
+
options, params = separate_params_and_options(options)
|
|
378
|
+
waiter = Waiters::ObjectExists.new(options)
|
|
379
|
+
yield_waiter_and_warn(waiter, &block) if block_given?
|
|
380
|
+
waiter.wait(params.merge(bucket: @bucket_name,
|
|
381
|
+
key: @key))
|
|
382
|
+
Object.new({
|
|
383
|
+
bucket_name: @bucket_name,
|
|
384
|
+
key: @key,
|
|
385
|
+
client: @client
|
|
386
|
+
})
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
# @param [Hash] options ({})
|
|
390
|
+
# @option options [Integer] :max_attempts (20)
|
|
391
|
+
# @option options [Float] :delay (5)
|
|
392
|
+
# @option options [Proc] :before_attempt
|
|
393
|
+
# @option options [Proc] :before_wait
|
|
394
|
+
# @return [Object]
|
|
395
|
+
def wait_until_not_exists(options = {}, &block)
|
|
396
|
+
options, params = separate_params_and_options(options)
|
|
397
|
+
waiter = Waiters::ObjectNotExists.new(options)
|
|
398
|
+
yield_waiter_and_warn(waiter, &block) if block_given?
|
|
399
|
+
waiter.wait(params.merge(bucket: @bucket_name,
|
|
400
|
+
key: @key))
|
|
401
|
+
Object.new({
|
|
402
|
+
bucket_name: @bucket_name,
|
|
403
|
+
key: @key,
|
|
404
|
+
client: @client
|
|
405
|
+
})
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
# @deprecated Use [Aws::S3::Client] #wait_until instead
|
|
409
|
+
#
|
|
410
|
+
# Waiter polls an API operation until a resource enters a desired
|
|
411
|
+
# state.
|
|
412
|
+
#
|
|
413
|
+
# @note The waiting operation is performed on a copy. The original resource
|
|
414
|
+
# remains unchanged.
|
|
415
|
+
#
|
|
416
|
+
# ## Basic Usage
|
|
417
|
+
#
|
|
418
|
+
# Waiter will polls until it is successful, it fails by
|
|
419
|
+
# entering a terminal state, or until a maximum number of attempts
|
|
420
|
+
# are made.
|
|
421
|
+
#
|
|
422
|
+
# # polls in a loop until condition is true
|
|
423
|
+
# resource.wait_until(options) {|resource| condition}
|
|
424
|
+
#
|
|
425
|
+
# ## Example
|
|
426
|
+
#
|
|
427
|
+
# instance.wait_until(max_attempts:10, delay:5) do |instance|
|
|
428
|
+
# instance.state.name == 'running'
|
|
429
|
+
# end
|
|
430
|
+
#
|
|
431
|
+
# ## Configuration
|
|
432
|
+
#
|
|
433
|
+
# You can configure the maximum number of polling attempts, and the
|
|
434
|
+
# delay (in seconds) between each polling attempt. The waiting condition is
|
|
435
|
+
# set by passing a block to {#wait_until}:
|
|
436
|
+
#
|
|
437
|
+
# # poll for ~25 seconds
|
|
438
|
+
# resource.wait_until(max_attempts:5,delay:5) {|resource|...}
|
|
439
|
+
#
|
|
440
|
+
# ## Callbacks
|
|
441
|
+
#
|
|
442
|
+
# You can be notified before each polling attempt and before each
|
|
443
|
+
# delay. If you throw `:success` or `:failure` from these callbacks,
|
|
444
|
+
# it will terminate the waiter.
|
|
445
|
+
#
|
|
446
|
+
# started_at = Time.now
|
|
447
|
+
# # poll for 1 hour, instead of a number of attempts
|
|
448
|
+
# proc = Proc.new do |attempts, response|
|
|
449
|
+
# throw :failure if Time.now - started_at > 3600
|
|
450
|
+
# end
|
|
451
|
+
#
|
|
452
|
+
# # disable max attempts
|
|
453
|
+
# instance.wait_until(before_wait:proc, max_attempts:nil) {...}
|
|
454
|
+
#
|
|
455
|
+
# ## Handling Errors
|
|
456
|
+
#
|
|
457
|
+
# When a waiter is successful, it returns the Resource. When a waiter
|
|
458
|
+
# fails, it raises an error.
|
|
459
|
+
#
|
|
460
|
+
# begin
|
|
461
|
+
# resource.wait_until(...)
|
|
462
|
+
# rescue Aws::Waiters::Errors::WaiterFailed
|
|
463
|
+
# # resource did not enter the desired state in time
|
|
464
|
+
# end
|
|
465
|
+
#
|
|
466
|
+
# @yieldparam [Resource] resource to be used in the waiting condition.
|
|
467
|
+
#
|
|
468
|
+
# @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter
|
|
469
|
+
# terminates because the waiter has entered a state that it will not
|
|
470
|
+
# transition out of, preventing success.
|
|
471
|
+
#
|
|
472
|
+
# yet successful.
|
|
473
|
+
#
|
|
474
|
+
# @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is
|
|
475
|
+
# encountered while polling for a resource that is not expected.
|
|
476
|
+
#
|
|
477
|
+
# @raise [NotImplementedError] Raised when the resource does not
|
|
478
|
+
#
|
|
479
|
+
# @option options [Integer] :max_attempts (10) Maximum number of
|
|
480
|
+
# attempts
|
|
481
|
+
# @option options [Integer] :delay (10) Delay between each
|
|
482
|
+
# attempt in seconds
|
|
483
|
+
# @option options [Proc] :before_attempt (nil) Callback
|
|
484
|
+
# invoked before each attempt
|
|
485
|
+
# @option options [Proc] :before_wait (nil) Callback
|
|
486
|
+
# invoked before each wait
|
|
487
|
+
# @return [Resource] if the waiter was successful
|
|
488
|
+
def wait_until(options = {}, &block)
|
|
489
|
+
self_copy = self.dup
|
|
490
|
+
attempts = 0
|
|
491
|
+
options[:max_attempts] = 10 unless options.key?(:max_attempts)
|
|
492
|
+
options[:delay] ||= 10
|
|
493
|
+
options[:poller] = Proc.new do
|
|
494
|
+
attempts += 1
|
|
495
|
+
if block.call(self_copy)
|
|
496
|
+
[:success, self_copy]
|
|
497
|
+
else
|
|
498
|
+
self_copy.reload unless attempts == options[:max_attempts]
|
|
499
|
+
:retry
|
|
500
|
+
end
|
|
501
|
+
end
|
|
502
|
+
Aws::Waiters::Waiter.new(options).wait({})
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
# @!group Actions
|
|
506
|
+
|
|
507
|
+
# @example Request syntax with placeholder values
|
|
508
|
+
#
|
|
509
|
+
# object.copy_from({
|
|
510
|
+
# acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
|
|
511
|
+
# cache_control: "CacheControl",
|
|
512
|
+
# content_disposition: "ContentDisposition",
|
|
513
|
+
# content_encoding: "ContentEncoding",
|
|
514
|
+
# content_language: "ContentLanguage",
|
|
515
|
+
# content_type: "ContentType",
|
|
516
|
+
# copy_source: "CopySource", # required
|
|
517
|
+
# copy_source_if_match: "CopySourceIfMatch",
|
|
518
|
+
# copy_source_if_modified_since: Time.now,
|
|
519
|
+
# copy_source_if_none_match: "CopySourceIfNoneMatch",
|
|
520
|
+
# copy_source_if_unmodified_since: Time.now,
|
|
521
|
+
# expires: Time.now,
|
|
522
|
+
# grant_full_control: "GrantFullControl",
|
|
523
|
+
# grant_read: "GrantRead",
|
|
524
|
+
# grant_read_acp: "GrantReadACP",
|
|
525
|
+
# grant_write_acp: "GrantWriteACP",
|
|
526
|
+
# metadata: {
|
|
527
|
+
# "MetadataKey" => "MetadataValue",
|
|
528
|
+
# },
|
|
529
|
+
# metadata_directive: "COPY", # accepts COPY, REPLACE
|
|
530
|
+
# tagging_directive: "COPY", # accepts COPY, REPLACE
|
|
531
|
+
# server_side_encryption: "AES256", # accepts AES256, aws:kms
|
|
532
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE
|
|
533
|
+
# website_redirect_location: "WebsiteRedirectLocation",
|
|
534
|
+
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
|
535
|
+
# sse_customer_key: "SSECustomerKey",
|
|
536
|
+
# sse_customer_key_md5: "SSECustomerKeyMD5",
|
|
537
|
+
# ssekms_key_id: "SSEKMSKeyId",
|
|
538
|
+
# ssekms_encryption_context: "SSEKMSEncryptionContext",
|
|
539
|
+
# copy_source_sse_customer_algorithm: "CopySourceSSECustomerAlgorithm",
|
|
540
|
+
# copy_source_sse_customer_key: "CopySourceSSECustomerKey",
|
|
541
|
+
# copy_source_sse_customer_key_md5: "CopySourceSSECustomerKeyMD5",
|
|
542
|
+
# request_payer: "requester", # accepts requester
|
|
543
|
+
# tagging: "TaggingHeader",
|
|
544
|
+
# object_lock_mode: "GOVERNANCE", # accepts GOVERNANCE, COMPLIANCE
|
|
545
|
+
# object_lock_retain_until_date: Time.now,
|
|
546
|
+
# object_lock_legal_hold_status: "ON", # accepts ON, OFF
|
|
547
|
+
# })
|
|
548
|
+
# @param [Hash] options ({})
|
|
549
|
+
# @option options [String] :acl
|
|
550
|
+
# The canned ACL to apply to the object.
|
|
551
|
+
# @option options [String] :cache_control
|
|
552
|
+
# Specifies caching behavior along the request/reply chain.
|
|
553
|
+
# @option options [String] :content_disposition
|
|
554
|
+
# Specifies presentational information for the object.
|
|
555
|
+
# @option options [String] :content_encoding
|
|
556
|
+
# Specifies what content encodings have been applied to the object and
|
|
557
|
+
# thus what decoding mechanisms must be applied to obtain the media-type
|
|
558
|
+
# referenced by the Content-Type header field.
|
|
559
|
+
# @option options [String] :content_language
|
|
560
|
+
# The language the content is in.
|
|
561
|
+
# @option options [String] :content_type
|
|
562
|
+
# A standard MIME type describing the format of the object data.
|
|
563
|
+
# @option options [required, String] :copy_source
|
|
564
|
+
# The name of the source bucket and key name of the source object,
|
|
565
|
+
# separated by a slash (/). Must be URL-encoded.
|
|
566
|
+
# @option options [String] :copy_source_if_match
|
|
567
|
+
# Copies the object if its entity tag (ETag) matches the specified tag.
|
|
568
|
+
# @option options [Time,DateTime,Date,Integer,String] :copy_source_if_modified_since
|
|
569
|
+
# Copies the object if it has been modified since the specified time.
|
|
570
|
+
# @option options [String] :copy_source_if_none_match
|
|
571
|
+
# Copies the object if its entity tag (ETag) is different than the
|
|
572
|
+
# specified ETag.
|
|
573
|
+
# @option options [Time,DateTime,Date,Integer,String] :copy_source_if_unmodified_since
|
|
574
|
+
# Copies the object if it hasn't been modified since the specified
|
|
575
|
+
# time.
|
|
576
|
+
# @option options [Time,DateTime,Date,Integer,String] :expires
|
|
577
|
+
# The date and time at which the object is no longer cacheable.
|
|
578
|
+
# @option options [String] :grant_full_control
|
|
579
|
+
# Gives the grantee READ, READ\_ACP, and WRITE\_ACP permissions on the
|
|
580
|
+
# object.
|
|
581
|
+
# @option options [String] :grant_read
|
|
582
|
+
# Allows grantee to read the object data and its metadata.
|
|
583
|
+
# @option options [String] :grant_read_acp
|
|
584
|
+
# Allows grantee to read the object ACL.
|
|
585
|
+
# @option options [String] :grant_write_acp
|
|
586
|
+
# Allows grantee to write the ACL for the applicable object.
|
|
587
|
+
# @option options [Hash<String,String>] :metadata
|
|
588
|
+
# A map of metadata to store with the object in S3.
|
|
589
|
+
# @option options [String] :metadata_directive
|
|
590
|
+
# Specifies whether the metadata is copied from the source object or
|
|
591
|
+
# replaced with metadata provided in the request.
|
|
592
|
+
# @option options [String] :tagging_directive
|
|
593
|
+
# Specifies whether the object tag-set are copied from the source object
|
|
594
|
+
# or replaced with tag-set provided in the request.
|
|
595
|
+
# @option options [String] :server_side_encryption
|
|
596
|
+
# The server-side encryption algorithm used when storing this object in
|
|
597
|
+
# Amazon S3 (for example, AES256, aws:kms).
|
|
598
|
+
# @option options [String] :storage_class
|
|
599
|
+
# The type of storage to use for the object. Defaults to 'STANDARD'.
|
|
600
|
+
# @option options [String] :website_redirect_location
|
|
601
|
+
# If the bucket is configured as a website, redirects requests for this
|
|
602
|
+
# object to another object in the same bucket or to an external URL.
|
|
603
|
+
# Amazon S3 stores the value of this header in the object metadata.
|
|
604
|
+
# @option options [String] :sse_customer_algorithm
|
|
605
|
+
# Specifies the algorithm to use to when encrypting the object (for
|
|
606
|
+
# example, AES256).
|
|
607
|
+
# @option options [String] :sse_customer_key
|
|
608
|
+
# Specifies the customer-provided encryption key for Amazon S3 to use in
|
|
609
|
+
# encrypting data. This value is used to store the object and then it is
|
|
610
|
+
# discarded; Amazon S3 does not store the encryption key. The key must
|
|
611
|
+
# be appropriate for use with the algorithm specified in the
|
|
612
|
+
# `x-amz-server-side-encryption-customer-algorithm` header.
|
|
613
|
+
# @option options [String] :sse_customer_key_md5
|
|
614
|
+
# Specifies the 128-bit MD5 digest of the encryption key according to
|
|
615
|
+
# RFC 1321. Amazon S3 uses this header for a message integrity check to
|
|
616
|
+
# ensure that the encryption key was transmitted without error.
|
|
617
|
+
# @option options [String] :ssekms_key_id
|
|
618
|
+
# Specifies the AWS KMS key ID to use for object encryption. All GET and
|
|
619
|
+
# PUT requests for an object protected by AWS KMS will fail if not made
|
|
620
|
+
# via SSL or using SigV4. For information about configuring using any of
|
|
621
|
+
# the officially supported AWS SDKs and AWS CLI, see [Specifying the
|
|
622
|
+
# Signature Version in Request Authentication][1] in the *Amazon S3
|
|
623
|
+
# Developer Guide*.
|
|
624
|
+
#
|
|
625
|
+
#
|
|
626
|
+
#
|
|
627
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version
|
|
628
|
+
# @option options [String] :ssekms_encryption_context
|
|
629
|
+
# Specifies the AWS KMS Encryption Context to use for object encryption.
|
|
630
|
+
# The value of this header is a base64-encoded UTF-8 string holding JSON
|
|
631
|
+
# with the encryption context key-value pairs.
|
|
632
|
+
# @option options [String] :copy_source_sse_customer_algorithm
|
|
633
|
+
# Specifies the algorithm to use when decrypting the source object (for
|
|
634
|
+
# example, AES256).
|
|
635
|
+
# @option options [String] :copy_source_sse_customer_key
|
|
636
|
+
# Specifies the customer-provided encryption key for Amazon S3 to use to
|
|
637
|
+
# decrypt the source object. The encryption key provided in this header
|
|
638
|
+
# must be one that was used when the source object was created.
|
|
639
|
+
# @option options [String] :copy_source_sse_customer_key_md5
|
|
640
|
+
# Specifies the 128-bit MD5 digest of the encryption key according to
|
|
641
|
+
# RFC 1321. Amazon S3 uses this header for a message integrity check to
|
|
642
|
+
# ensure that the encryption key was transmitted without error.
|
|
643
|
+
# @option options [String] :request_payer
|
|
644
|
+
# Confirms that the requester knows that they will be charged for the
|
|
645
|
+
# request. Bucket owners need not specify this parameter in their
|
|
646
|
+
# requests. For information about downloading objects from requester
|
|
647
|
+
# pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
|
|
648
|
+
# in the *Amazon S3 Developer Guide*.
|
|
649
|
+
#
|
|
650
|
+
#
|
|
651
|
+
#
|
|
652
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
|
653
|
+
# @option options [String] :tagging
|
|
654
|
+
# The tag-set for the object destination object this value must be used
|
|
655
|
+
# in conjunction with the `TaggingDirective`. The tag-set must be
|
|
656
|
+
# encoded as URL Query parameters.
|
|
657
|
+
# @option options [String] :object_lock_mode
|
|
658
|
+
# The Object Lock mode that you want to apply to the copied object.
|
|
659
|
+
# @option options [Time,DateTime,Date,Integer,String] :object_lock_retain_until_date
|
|
660
|
+
# The date and time when you want the copied object's Object Lock to
|
|
661
|
+
# expire.
|
|
662
|
+
# @option options [String] :object_lock_legal_hold_status
|
|
663
|
+
# Specifies whether you want to apply a Legal Hold to the copied object.
|
|
664
|
+
# @return [Types::CopyObjectOutput]
|
|
665
|
+
def copy_from(options = {})
|
|
666
|
+
options = options.merge(
|
|
667
|
+
bucket: @bucket_name,
|
|
668
|
+
key: @key
|
|
669
|
+
)
|
|
670
|
+
resp = @client.copy_object(options)
|
|
671
|
+
resp.data
|
|
672
|
+
end
|
|
673
|
+
|
|
674
|
+
# @example Request syntax with placeholder values
|
|
675
|
+
#
|
|
676
|
+
# object.delete({
|
|
677
|
+
# mfa: "MFA",
|
|
678
|
+
# version_id: "ObjectVersionId",
|
|
679
|
+
# request_payer: "requester", # accepts requester
|
|
680
|
+
# bypass_governance_retention: false,
|
|
681
|
+
# })
|
|
682
|
+
# @param [Hash] options ({})
|
|
683
|
+
# @option options [String] :mfa
|
|
684
|
+
# The concatenation of the authentication device's serial number, a
|
|
685
|
+
# space, and the value that is displayed on your authentication device.
|
|
686
|
+
# Required to permanently delete a versioned object if versioning is
|
|
687
|
+
# configured with MFA delete enabled.
|
|
688
|
+
# @option options [String] :version_id
|
|
689
|
+
# VersionId used to reference a specific version of the object.
|
|
690
|
+
# @option options [String] :request_payer
|
|
691
|
+
# Confirms that the requester knows that they will be charged for the
|
|
692
|
+
# request. Bucket owners need not specify this parameter in their
|
|
693
|
+
# requests. For information about downloading objects from requester
|
|
694
|
+
# pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
|
|
695
|
+
# in the *Amazon S3 Developer Guide*.
|
|
696
|
+
#
|
|
697
|
+
#
|
|
698
|
+
#
|
|
699
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
|
700
|
+
# @option options [Boolean] :bypass_governance_retention
|
|
701
|
+
# Indicates whether S3 Object Lock should bypass Governance-mode
|
|
702
|
+
# restrictions to process this operation.
|
|
703
|
+
# @return [Types::DeleteObjectOutput]
|
|
704
|
+
def delete(options = {})
|
|
705
|
+
options = options.merge(
|
|
706
|
+
bucket: @bucket_name,
|
|
707
|
+
key: @key
|
|
708
|
+
)
|
|
709
|
+
resp = @client.delete_object(options)
|
|
710
|
+
resp.data
|
|
711
|
+
end
|
|
712
|
+
|
|
713
|
+
# @example Request syntax with placeholder values
|
|
714
|
+
#
|
|
715
|
+
# object.get({
|
|
716
|
+
# if_match: "IfMatch",
|
|
717
|
+
# if_modified_since: Time.now,
|
|
718
|
+
# if_none_match: "IfNoneMatch",
|
|
719
|
+
# if_unmodified_since: Time.now,
|
|
720
|
+
# range: "Range",
|
|
721
|
+
# response_cache_control: "ResponseCacheControl",
|
|
722
|
+
# response_content_disposition: "ResponseContentDisposition",
|
|
723
|
+
# response_content_encoding: "ResponseContentEncoding",
|
|
724
|
+
# response_content_language: "ResponseContentLanguage",
|
|
725
|
+
# response_content_type: "ResponseContentType",
|
|
726
|
+
# response_expires: Time.now,
|
|
727
|
+
# version_id: "ObjectVersionId",
|
|
728
|
+
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
|
729
|
+
# sse_customer_key: "SSECustomerKey",
|
|
730
|
+
# sse_customer_key_md5: "SSECustomerKeyMD5",
|
|
731
|
+
# request_payer: "requester", # accepts requester
|
|
732
|
+
# part_number: 1,
|
|
733
|
+
# })
|
|
734
|
+
# @param [Hash] options ({})
|
|
735
|
+
# @option options [String] :if_match
|
|
736
|
+
# Return the object only if its entity tag (ETag) is the same as the one
|
|
737
|
+
# specified, otherwise return a 412 (precondition failed).
|
|
738
|
+
# @option options [Time,DateTime,Date,Integer,String] :if_modified_since
|
|
739
|
+
# Return the object only if it has been modified since the specified
|
|
740
|
+
# time, otherwise return a 304 (not modified).
|
|
741
|
+
# @option options [String] :if_none_match
|
|
742
|
+
# Return the object only if its entity tag (ETag) is different from the
|
|
743
|
+
# one specified, otherwise return a 304 (not modified).
|
|
744
|
+
# @option options [Time,DateTime,Date,Integer,String] :if_unmodified_since
|
|
745
|
+
# Return the object only if it has not been modified since the specified
|
|
746
|
+
# time, otherwise return a 412 (precondition failed).
|
|
747
|
+
# @option options [String] :range
|
|
748
|
+
# Downloads the specified range bytes of an object. For more information
|
|
749
|
+
# about the HTTP Range header, see
|
|
750
|
+
# [https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35][1].
|
|
751
|
+
#
|
|
752
|
+
# <note markdown="1"> Amazon S3 doesn't support retrieving multiple ranges of data per
|
|
753
|
+
# `GET` request.
|
|
754
|
+
#
|
|
755
|
+
# </note>
|
|
756
|
+
#
|
|
757
|
+
#
|
|
758
|
+
#
|
|
759
|
+
# [1]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35
|
|
760
|
+
# @option options [String] :response_cache_control
|
|
761
|
+
# Sets the `Cache-Control` header of the response.
|
|
762
|
+
# @option options [String] :response_content_disposition
|
|
763
|
+
# Sets the `Content-Disposition` header of the response
|
|
764
|
+
# @option options [String] :response_content_encoding
|
|
765
|
+
# Sets the `Content-Encoding` header of the response.
|
|
766
|
+
# @option options [String] :response_content_language
|
|
767
|
+
# Sets the `Content-Language` header of the response.
|
|
768
|
+
# @option options [String] :response_content_type
|
|
769
|
+
# Sets the `Content-Type` header of the response.
|
|
770
|
+
# @option options [Time,DateTime,Date,Integer,String] :response_expires
|
|
771
|
+
# Sets the `Expires` header of the response.
|
|
772
|
+
# @option options [String] :version_id
|
|
773
|
+
# VersionId used to reference a specific version of the object.
|
|
774
|
+
# @option options [String] :sse_customer_algorithm
|
|
775
|
+
# Specifies the algorithm to use to when encrypting the object (for
|
|
776
|
+
# example, AES256).
|
|
777
|
+
# @option options [String] :sse_customer_key
|
|
778
|
+
# Specifies the customer-provided encryption key for Amazon S3 to use in
|
|
779
|
+
# encrypting data. This value is used to store the object and then it is
|
|
780
|
+
# discarded; Amazon S3 does not store the encryption key. The key must
|
|
781
|
+
# be appropriate for use with the algorithm specified in the
|
|
782
|
+
# `x-amz-server-side-encryption-customer-algorithm` header.
|
|
783
|
+
# @option options [String] :sse_customer_key_md5
|
|
784
|
+
# Specifies the 128-bit MD5 digest of the encryption key according to
|
|
785
|
+
# RFC 1321. Amazon S3 uses this header for a message integrity check to
|
|
786
|
+
# ensure that the encryption key was transmitted without error.
|
|
787
|
+
# @option options [String] :request_payer
|
|
788
|
+
# Confirms that the requester knows that they will be charged for the
|
|
789
|
+
# request. Bucket owners need not specify this parameter in their
|
|
790
|
+
# requests. For information about downloading objects from requester
|
|
791
|
+
# pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
|
|
792
|
+
# in the *Amazon S3 Developer Guide*.
|
|
793
|
+
#
|
|
794
|
+
#
|
|
795
|
+
#
|
|
796
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
|
797
|
+
# @option options [Integer] :part_number
|
|
798
|
+
# Part number of the object being read. This is a positive integer
|
|
799
|
+
# between 1 and 10,000. Effectively performs a 'ranged' GET request
|
|
800
|
+
# for the part specified. Useful for downloading just a part of an
|
|
801
|
+
# object.
|
|
802
|
+
# @return [Types::GetObjectOutput]
|
|
803
|
+
def get(options = {}, &block)
|
|
804
|
+
options = options.merge(
|
|
805
|
+
bucket: @bucket_name,
|
|
806
|
+
key: @key
|
|
807
|
+
)
|
|
808
|
+
resp = @client.get_object(options, &block)
|
|
809
|
+
resp.data
|
|
810
|
+
end
|
|
811
|
+
|
|
812
|
+
# @example Request syntax with placeholder values
|
|
813
|
+
#
|
|
814
|
+
# multipartupload = object.initiate_multipart_upload({
|
|
815
|
+
# acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
|
|
816
|
+
# cache_control: "CacheControl",
|
|
817
|
+
# content_disposition: "ContentDisposition",
|
|
818
|
+
# content_encoding: "ContentEncoding",
|
|
819
|
+
# content_language: "ContentLanguage",
|
|
820
|
+
# content_type: "ContentType",
|
|
821
|
+
# expires: Time.now,
|
|
822
|
+
# grant_full_control: "GrantFullControl",
|
|
823
|
+
# grant_read: "GrantRead",
|
|
824
|
+
# grant_read_acp: "GrantReadACP",
|
|
825
|
+
# grant_write_acp: "GrantWriteACP",
|
|
826
|
+
# metadata: {
|
|
827
|
+
# "MetadataKey" => "MetadataValue",
|
|
828
|
+
# },
|
|
829
|
+
# server_side_encryption: "AES256", # accepts AES256, aws:kms
|
|
830
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE
|
|
831
|
+
# website_redirect_location: "WebsiteRedirectLocation",
|
|
832
|
+
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
|
833
|
+
# sse_customer_key: "SSECustomerKey",
|
|
834
|
+
# sse_customer_key_md5: "SSECustomerKeyMD5",
|
|
835
|
+
# ssekms_key_id: "SSEKMSKeyId",
|
|
836
|
+
# ssekms_encryption_context: "SSEKMSEncryptionContext",
|
|
837
|
+
# request_payer: "requester", # accepts requester
|
|
838
|
+
# tagging: "TaggingHeader",
|
|
839
|
+
# object_lock_mode: "GOVERNANCE", # accepts GOVERNANCE, COMPLIANCE
|
|
840
|
+
# object_lock_retain_until_date: Time.now,
|
|
841
|
+
# object_lock_legal_hold_status: "ON", # accepts ON, OFF
|
|
842
|
+
# })
|
|
843
|
+
# @param [Hash] options ({})
|
|
844
|
+
# @option options [String] :acl
|
|
845
|
+
# The canned ACL to apply to the object.
|
|
846
|
+
# @option options [String] :cache_control
|
|
847
|
+
# Specifies caching behavior along the request/reply chain.
|
|
848
|
+
# @option options [String] :content_disposition
|
|
849
|
+
# Specifies presentational information for the object.
|
|
850
|
+
# @option options [String] :content_encoding
|
|
851
|
+
# Specifies what content encodings have been applied to the object and
|
|
852
|
+
# thus what decoding mechanisms must be applied to obtain the media-type
|
|
853
|
+
# referenced by the Content-Type header field.
|
|
854
|
+
# @option options [String] :content_language
|
|
855
|
+
# The language the content is in.
|
|
856
|
+
# @option options [String] :content_type
|
|
857
|
+
# A standard MIME type describing the format of the object data.
|
|
858
|
+
# @option options [Time,DateTime,Date,Integer,String] :expires
|
|
859
|
+
# The date and time at which the object is no longer cacheable.
|
|
860
|
+
# @option options [String] :grant_full_control
|
|
861
|
+
# Gives the grantee READ, READ\_ACP, and WRITE\_ACP permissions on the
|
|
862
|
+
# object.
|
|
863
|
+
# @option options [String] :grant_read
|
|
864
|
+
# Allows grantee to read the object data and its metadata.
|
|
865
|
+
# @option options [String] :grant_read_acp
|
|
866
|
+
# Allows grantee to read the object ACL.
|
|
867
|
+
# @option options [String] :grant_write_acp
|
|
868
|
+
# Allows grantee to write the ACL for the applicable object.
|
|
869
|
+
# @option options [Hash<String,String>] :metadata
|
|
870
|
+
# A map of metadata to store with the object in S3.
|
|
871
|
+
# @option options [String] :server_side_encryption
|
|
872
|
+
# The server-side encryption algorithm used when storing this object in
|
|
873
|
+
# Amazon S3 (for example, AES256, aws:kms).
|
|
874
|
+
# @option options [String] :storage_class
|
|
875
|
+
# The type of storage to use for the object. Defaults to 'STANDARD'.
|
|
876
|
+
# @option options [String] :website_redirect_location
|
|
877
|
+
# If the bucket is configured as a website, redirects requests for this
|
|
878
|
+
# object to another object in the same bucket or to an external URL.
|
|
879
|
+
# Amazon S3 stores the value of this header in the object metadata.
|
|
880
|
+
# @option options [String] :sse_customer_algorithm
|
|
881
|
+
# Specifies the algorithm to use to when encrypting the object (for
|
|
882
|
+
# example, AES256).
|
|
883
|
+
# @option options [String] :sse_customer_key
|
|
884
|
+
# Specifies the customer-provided encryption key for Amazon S3 to use in
|
|
885
|
+
# encrypting data. This value is used to store the object and then it is
|
|
886
|
+
# discarded; Amazon S3 does not store the encryption key. The key must
|
|
887
|
+
# be appropriate for use with the algorithm specified in the
|
|
888
|
+
# `x-amz-server-side-encryption-customer-algorithm` header.
|
|
889
|
+
# @option options [String] :sse_customer_key_md5
|
|
890
|
+
# Specifies the 128-bit MD5 digest of the encryption key according to
|
|
891
|
+
# RFC 1321. Amazon S3 uses this header for a message integrity check to
|
|
892
|
+
# ensure that the encryption key was transmitted without error.
|
|
893
|
+
# @option options [String] :ssekms_key_id
|
|
894
|
+
# Specifies the ID of the symmetric customer managed AWS KMS CMK to use
|
|
895
|
+
# for object encryption. All GET and PUT requests for an object
|
|
896
|
+
# protected by AWS KMS will fail if not made via SSL or using SigV4. For
|
|
897
|
+
# information about configuring using any of the officially supported
|
|
898
|
+
# AWS SDKs and AWS CLI, see [Specifying the Signature Version in Request
|
|
899
|
+
# Authentication][1] in the *Amazon S3 Developer Guide*.
|
|
900
|
+
#
|
|
901
|
+
#
|
|
902
|
+
#
|
|
903
|
+
# [1]: https://docs.aws.amazon.com/http:/docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version
|
|
904
|
+
# @option options [String] :ssekms_encryption_context
|
|
905
|
+
# Specifies the AWS KMS Encryption Context to use for object encryption.
|
|
906
|
+
# The value of this header is a base64-encoded UTF-8 string holding JSON
|
|
907
|
+
# with the encryption context key-value pairs.
|
|
908
|
+
# @option options [String] :request_payer
|
|
909
|
+
# Confirms that the requester knows that they will be charged for the
|
|
910
|
+
# request. Bucket owners need not specify this parameter in their
|
|
911
|
+
# requests. For information about downloading objects from requester
|
|
912
|
+
# pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
|
|
913
|
+
# in the *Amazon S3 Developer Guide*.
|
|
914
|
+
#
|
|
915
|
+
#
|
|
916
|
+
#
|
|
917
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
|
918
|
+
# @option options [String] :tagging
|
|
919
|
+
# The tag-set for the object. The tag-set must be encoded as URL Query
|
|
920
|
+
# parameters.
|
|
921
|
+
# @option options [String] :object_lock_mode
|
|
922
|
+
# Specifies the Object Lock mode that you want to apply to the uploaded
|
|
923
|
+
# object.
|
|
924
|
+
# @option options [Time,DateTime,Date,Integer,String] :object_lock_retain_until_date
|
|
925
|
+
# Specifies the date and time when you want the Object Lock to expire.
|
|
926
|
+
# @option options [String] :object_lock_legal_hold_status
|
|
927
|
+
# Specifies whether you want to apply a Legal Hold to the uploaded
|
|
928
|
+
# object.
|
|
929
|
+
# @return [MultipartUpload]
|
|
930
|
+
def initiate_multipart_upload(options = {})
|
|
931
|
+
options = options.merge(
|
|
932
|
+
bucket: @bucket_name,
|
|
933
|
+
key: @key
|
|
934
|
+
)
|
|
935
|
+
resp = @client.create_multipart_upload(options)
|
|
936
|
+
MultipartUpload.new(
|
|
937
|
+
bucket_name: @bucket_name,
|
|
938
|
+
object_key: @key,
|
|
939
|
+
id: resp.data.upload_id,
|
|
940
|
+
client: @client
|
|
941
|
+
)
|
|
942
|
+
end
|
|
943
|
+
|
|
944
|
+
# @example Request syntax with placeholder values
|
|
945
|
+
#
|
|
946
|
+
# object.put({
|
|
947
|
+
# acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
|
|
948
|
+
# body: source_file,
|
|
949
|
+
# cache_control: "CacheControl",
|
|
950
|
+
# content_disposition: "ContentDisposition",
|
|
951
|
+
# content_encoding: "ContentEncoding",
|
|
952
|
+
# content_language: "ContentLanguage",
|
|
953
|
+
# content_length: 1,
|
|
954
|
+
# content_md5: "ContentMD5",
|
|
955
|
+
# content_type: "ContentType",
|
|
956
|
+
# expires: Time.now,
|
|
957
|
+
# grant_full_control: "GrantFullControl",
|
|
958
|
+
# grant_read: "GrantRead",
|
|
959
|
+
# grant_read_acp: "GrantReadACP",
|
|
960
|
+
# grant_write_acp: "GrantWriteACP",
|
|
961
|
+
# metadata: {
|
|
962
|
+
# "MetadataKey" => "MetadataValue",
|
|
963
|
+
# },
|
|
964
|
+
# server_side_encryption: "AES256", # accepts AES256, aws:kms
|
|
965
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE
|
|
966
|
+
# website_redirect_location: "WebsiteRedirectLocation",
|
|
967
|
+
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
|
968
|
+
# sse_customer_key: "SSECustomerKey",
|
|
969
|
+
# sse_customer_key_md5: "SSECustomerKeyMD5",
|
|
970
|
+
# ssekms_key_id: "SSEKMSKeyId",
|
|
971
|
+
# ssekms_encryption_context: "SSEKMSEncryptionContext",
|
|
972
|
+
# request_payer: "requester", # accepts requester
|
|
973
|
+
# tagging: "TaggingHeader",
|
|
974
|
+
# object_lock_mode: "GOVERNANCE", # accepts GOVERNANCE, COMPLIANCE
|
|
975
|
+
# object_lock_retain_until_date: Time.now,
|
|
976
|
+
# object_lock_legal_hold_status: "ON", # accepts ON, OFF
|
|
977
|
+
# })
|
|
978
|
+
# @param [Hash] options ({})
|
|
979
|
+
# @option options [String] :acl
|
|
980
|
+
# The canned ACL to apply to the object. For more information, see
|
|
981
|
+
# [Canned ACL][1].
|
|
982
|
+
#
|
|
983
|
+
#
|
|
984
|
+
#
|
|
985
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#CannedACL
|
|
986
|
+
# @option options [String, IO] :body
|
|
987
|
+
# Object data.
|
|
988
|
+
# @option options [String] :cache_control
|
|
989
|
+
# Can be used to specify caching behavior along the request/reply chain.
|
|
990
|
+
# For more information, see
|
|
991
|
+
# [http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9][1].
|
|
992
|
+
#
|
|
993
|
+
#
|
|
994
|
+
#
|
|
995
|
+
# [1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
|
|
996
|
+
# @option options [String] :content_disposition
|
|
997
|
+
# Specifies presentational information for the object. For more
|
|
998
|
+
# information, see
|
|
999
|
+
# [http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1][1].
|
|
1000
|
+
#
|
|
1001
|
+
#
|
|
1002
|
+
#
|
|
1003
|
+
# [1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1
|
|
1004
|
+
# @option options [String] :content_encoding
|
|
1005
|
+
# Specifies what content encodings have been applied to the object and
|
|
1006
|
+
# thus what decoding mechanisms must be applied to obtain the media-type
|
|
1007
|
+
# referenced by the Content-Type header field. For more information, see
|
|
1008
|
+
# [http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11][1].
|
|
1009
|
+
#
|
|
1010
|
+
#
|
|
1011
|
+
#
|
|
1012
|
+
# [1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11
|
|
1013
|
+
# @option options [String] :content_language
|
|
1014
|
+
# The language the content is in.
|
|
1015
|
+
# @option options [Integer] :content_length
|
|
1016
|
+
# Size of the body in bytes. This parameter is useful when the size of
|
|
1017
|
+
# the body cannot be determined automatically. For more information, see
|
|
1018
|
+
# [http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13][1].
|
|
1019
|
+
#
|
|
1020
|
+
#
|
|
1021
|
+
#
|
|
1022
|
+
# [1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13
|
|
1023
|
+
# @option options [String] :content_md5
|
|
1024
|
+
# The base64-encoded 128-bit MD5 digest of the message (without the
|
|
1025
|
+
# headers) according to RFC 1864. This header can be used as a message
|
|
1026
|
+
# integrity check to verify that the data is the same data that was
|
|
1027
|
+
# originally sent. Although it is optional, we recommend using the
|
|
1028
|
+
# Content-MD5 mechanism as an end-to-end integrity check. For more
|
|
1029
|
+
# information about REST request authentication, see [REST
|
|
1030
|
+
# Authentication][1].
|
|
1031
|
+
#
|
|
1032
|
+
#
|
|
1033
|
+
#
|
|
1034
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html
|
|
1035
|
+
# @option options [String] :content_type
|
|
1036
|
+
# A standard MIME type describing the format of the contents. For more
|
|
1037
|
+
# information, see
|
|
1038
|
+
# [http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17][1].
|
|
1039
|
+
#
|
|
1040
|
+
#
|
|
1041
|
+
#
|
|
1042
|
+
# [1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17
|
|
1043
|
+
# @option options [Time,DateTime,Date,Integer,String] :expires
|
|
1044
|
+
# The date and time at which the object is no longer cacheable. For more
|
|
1045
|
+
# information, see
|
|
1046
|
+
# [http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21][1].
|
|
1047
|
+
#
|
|
1048
|
+
#
|
|
1049
|
+
#
|
|
1050
|
+
# [1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21
|
|
1051
|
+
# @option options [String] :grant_full_control
|
|
1052
|
+
# Gives the grantee READ, READ\_ACP, and WRITE\_ACP permissions on the
|
|
1053
|
+
# object.
|
|
1054
|
+
# @option options [String] :grant_read
|
|
1055
|
+
# Allows grantee to read the object data and its metadata.
|
|
1056
|
+
# @option options [String] :grant_read_acp
|
|
1057
|
+
# Allows grantee to read the object ACL.
|
|
1058
|
+
# @option options [String] :grant_write_acp
|
|
1059
|
+
# Allows grantee to write the ACL for the applicable object.
|
|
1060
|
+
# @option options [Hash<String,String>] :metadata
|
|
1061
|
+
# A map of metadata to store with the object in S3.
|
|
1062
|
+
# @option options [String] :server_side_encryption
|
|
1063
|
+
# The server-side encryption algorithm used when storing this object in
|
|
1064
|
+
# Amazon S3 (for example, AES256, aws:kms).
|
|
1065
|
+
# @option options [String] :storage_class
|
|
1066
|
+
# If you don't specify, S3 Standard is the default storage class.
|
|
1067
|
+
# Amazon S3 supports other storage classes.
|
|
1068
|
+
# @option options [String] :website_redirect_location
|
|
1069
|
+
# If the bucket is configured as a website, redirects requests for this
|
|
1070
|
+
# object to another object in the same bucket or to an external URL.
|
|
1071
|
+
# Amazon S3 stores the value of this header in the object metadata. For
|
|
1072
|
+
# information about object metadata, see [Object Key and Metadata][1].
|
|
1073
|
+
#
|
|
1074
|
+
# In the following example, the request header sets the redirect to an
|
|
1075
|
+
# object (anotherPage.html) in the same bucket:
|
|
1076
|
+
#
|
|
1077
|
+
# `x-amz-website-redirect-location: /anotherPage.html`
|
|
1078
|
+
#
|
|
1079
|
+
# In the following example, the request header sets the object redirect
|
|
1080
|
+
# to another website:
|
|
1081
|
+
#
|
|
1082
|
+
# `x-amz-website-redirect-location: http://www.example.com/`
|
|
1083
|
+
#
|
|
1084
|
+
# For more information about website hosting in Amazon S3, see [Hosting
|
|
1085
|
+
# Websites on Amazon S3][2] and [How to Configure Website Page
|
|
1086
|
+
# Redirects][3].
|
|
1087
|
+
#
|
|
1088
|
+
#
|
|
1089
|
+
#
|
|
1090
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html
|
|
1091
|
+
# [2]: https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html
|
|
1092
|
+
# [3]: https://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html
|
|
1093
|
+
# @option options [String] :sse_customer_algorithm
|
|
1094
|
+
# Specifies the algorithm to use to when encrypting the object (for
|
|
1095
|
+
# example, AES256).
|
|
1096
|
+
# @option options [String] :sse_customer_key
|
|
1097
|
+
# Specifies the customer-provided encryption key for Amazon S3 to use in
|
|
1098
|
+
# encrypting data. This value is used to store the object and then it is
|
|
1099
|
+
# discarded; Amazon S3 does not store the encryption key. The key must
|
|
1100
|
+
# be appropriate for use with the algorithm specified in the
|
|
1101
|
+
# `x-amz-server-side-encryption-customer-algorithm` header.
|
|
1102
|
+
# @option options [String] :sse_customer_key_md5
|
|
1103
|
+
# Specifies the 128-bit MD5 digest of the encryption key according to
|
|
1104
|
+
# RFC 1321. Amazon S3 uses this header for a message integrity check to
|
|
1105
|
+
# ensure that the encryption key was transmitted without error.
|
|
1106
|
+
# @option options [String] :ssekms_key_id
|
|
1107
|
+
# If `x-amz-server-side-encryption` is present and has the value of
|
|
1108
|
+
# `aws:kms`, this header specifies the ID of the AWS Key Management
|
|
1109
|
+
# Service (AWS KMS) symmetrical customer managed customer master key
|
|
1110
|
+
# (CMK) that was used for the object.
|
|
1111
|
+
#
|
|
1112
|
+
# If the value of `x-amz-server-side-encryption` is `aws:kms`, this
|
|
1113
|
+
# header specifies the ID of the symmetric customer managed AWS KMS CMK
|
|
1114
|
+
# that will be used for the object. If you specify
|
|
1115
|
+
# `x-amz-server-side-encryption:aws:kms`, but do not provide`
|
|
1116
|
+
# x-amz-server-side-encryption-aws-kms-key-id`, Amazon S3 uses the AWS
|
|
1117
|
+
# managed CMK in AWS to protect the data.
|
|
1118
|
+
# @option options [String] :ssekms_encryption_context
|
|
1119
|
+
# Specifies the AWS KMS Encryption Context to use for object encryption.
|
|
1120
|
+
# The value of this header is a base64-encoded UTF-8 string holding JSON
|
|
1121
|
+
# with the encryption context key-value pairs.
|
|
1122
|
+
# @option options [String] :request_payer
|
|
1123
|
+
# Confirms that the requester knows that they will be charged for the
|
|
1124
|
+
# request. Bucket owners need not specify this parameter in their
|
|
1125
|
+
# requests. For information about downloading objects from requester
|
|
1126
|
+
# pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
|
|
1127
|
+
# in the *Amazon S3 Developer Guide*.
|
|
1128
|
+
#
|
|
1129
|
+
#
|
|
1130
|
+
#
|
|
1131
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
|
1132
|
+
# @option options [String] :tagging
|
|
1133
|
+
# The tag-set for the object. The tag-set must be encoded as URL Query
|
|
1134
|
+
# parameters. (For example, "Key1=Value1")
|
|
1135
|
+
# @option options [String] :object_lock_mode
|
|
1136
|
+
# The Object Lock mode that you want to apply to this object.
|
|
1137
|
+
# @option options [Time,DateTime,Date,Integer,String] :object_lock_retain_until_date
|
|
1138
|
+
# The date and time when you want this object's Object Lock to expire.
|
|
1139
|
+
# @option options [String] :object_lock_legal_hold_status
|
|
1140
|
+
# Specifies whether a legal hold will be applied to this object. For
|
|
1141
|
+
# more information about S3 Object Lock, see [Object Lock][1].
|
|
1142
|
+
#
|
|
1143
|
+
#
|
|
1144
|
+
#
|
|
1145
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lock.html
|
|
1146
|
+
# @return [Types::PutObjectOutput]
|
|
1147
|
+
def put(options = {})
|
|
1148
|
+
options = options.merge(
|
|
1149
|
+
bucket: @bucket_name,
|
|
1150
|
+
key: @key
|
|
1151
|
+
)
|
|
1152
|
+
resp = @client.put_object(options)
|
|
1153
|
+
resp.data
|
|
1154
|
+
end
|
|
1155
|
+
|
|
1156
|
+
# @example Request syntax with placeholder values
|
|
1157
|
+
#
|
|
1158
|
+
# object.restore_object({
|
|
1159
|
+
# version_id: "ObjectVersionId",
|
|
1160
|
+
# restore_request: {
|
|
1161
|
+
# days: 1,
|
|
1162
|
+
# glacier_job_parameters: {
|
|
1163
|
+
# tier: "Standard", # required, accepts Standard, Bulk, Expedited
|
|
1164
|
+
# },
|
|
1165
|
+
# type: "SELECT", # accepts SELECT
|
|
1166
|
+
# tier: "Standard", # accepts Standard, Bulk, Expedited
|
|
1167
|
+
# description: "Description",
|
|
1168
|
+
# select_parameters: {
|
|
1169
|
+
# input_serialization: { # required
|
|
1170
|
+
# csv: {
|
|
1171
|
+
# file_header_info: "USE", # accepts USE, IGNORE, NONE
|
|
1172
|
+
# comments: "Comments",
|
|
1173
|
+
# quote_escape_character: "QuoteEscapeCharacter",
|
|
1174
|
+
# record_delimiter: "RecordDelimiter",
|
|
1175
|
+
# field_delimiter: "FieldDelimiter",
|
|
1176
|
+
# quote_character: "QuoteCharacter",
|
|
1177
|
+
# allow_quoted_record_delimiter: false,
|
|
1178
|
+
# },
|
|
1179
|
+
# compression_type: "NONE", # accepts NONE, GZIP, BZIP2
|
|
1180
|
+
# json: {
|
|
1181
|
+
# type: "DOCUMENT", # accepts DOCUMENT, LINES
|
|
1182
|
+
# },
|
|
1183
|
+
# parquet: {
|
|
1184
|
+
# },
|
|
1185
|
+
# },
|
|
1186
|
+
# expression_type: "SQL", # required, accepts SQL
|
|
1187
|
+
# expression: "Expression", # required
|
|
1188
|
+
# output_serialization: { # required
|
|
1189
|
+
# csv: {
|
|
1190
|
+
# quote_fields: "ALWAYS", # accepts ALWAYS, ASNEEDED
|
|
1191
|
+
# quote_escape_character: "QuoteEscapeCharacter",
|
|
1192
|
+
# record_delimiter: "RecordDelimiter",
|
|
1193
|
+
# field_delimiter: "FieldDelimiter",
|
|
1194
|
+
# quote_character: "QuoteCharacter",
|
|
1195
|
+
# },
|
|
1196
|
+
# json: {
|
|
1197
|
+
# record_delimiter: "RecordDelimiter",
|
|
1198
|
+
# },
|
|
1199
|
+
# },
|
|
1200
|
+
# },
|
|
1201
|
+
# output_location: {
|
|
1202
|
+
# s3: {
|
|
1203
|
+
# bucket_name: "BucketName", # required
|
|
1204
|
+
# prefix: "LocationPrefix", # required
|
|
1205
|
+
# encryption: {
|
|
1206
|
+
# encryption_type: "AES256", # required, accepts AES256, aws:kms
|
|
1207
|
+
# kms_key_id: "SSEKMSKeyId",
|
|
1208
|
+
# kms_context: "KMSContext",
|
|
1209
|
+
# },
|
|
1210
|
+
# canned_acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
|
|
1211
|
+
# access_control_list: [
|
|
1212
|
+
# {
|
|
1213
|
+
# grantee: {
|
|
1214
|
+
# display_name: "DisplayName",
|
|
1215
|
+
# email_address: "EmailAddress",
|
|
1216
|
+
# id: "ID",
|
|
1217
|
+
# type: "CanonicalUser", # required, accepts CanonicalUser, AmazonCustomerByEmail, Group
|
|
1218
|
+
# uri: "URI",
|
|
1219
|
+
# },
|
|
1220
|
+
# permission: "FULL_CONTROL", # accepts FULL_CONTROL, WRITE, WRITE_ACP, READ, READ_ACP
|
|
1221
|
+
# },
|
|
1222
|
+
# ],
|
|
1223
|
+
# tagging: {
|
|
1224
|
+
# tag_set: [ # required
|
|
1225
|
+
# {
|
|
1226
|
+
# key: "ObjectKey", # required
|
|
1227
|
+
# value: "Value", # required
|
|
1228
|
+
# },
|
|
1229
|
+
# ],
|
|
1230
|
+
# },
|
|
1231
|
+
# user_metadata: [
|
|
1232
|
+
# {
|
|
1233
|
+
# name: "MetadataKey",
|
|
1234
|
+
# value: "MetadataValue",
|
|
1235
|
+
# },
|
|
1236
|
+
# ],
|
|
1237
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE
|
|
1238
|
+
# },
|
|
1239
|
+
# },
|
|
1240
|
+
# },
|
|
1241
|
+
# request_payer: "requester", # accepts requester
|
|
1242
|
+
# })
|
|
1243
|
+
# @param [Hash] options ({})
|
|
1244
|
+
# @option options [String] :version_id
|
|
1245
|
+
# VersionId used to reference a specific version of the object.
|
|
1246
|
+
# @option options [Types::RestoreRequest] :restore_request
|
|
1247
|
+
# Container for restore job parameters.
|
|
1248
|
+
# @option options [String] :request_payer
|
|
1249
|
+
# Confirms that the requester knows that they will be charged for the
|
|
1250
|
+
# request. Bucket owners need not specify this parameter in their
|
|
1251
|
+
# requests. For information about downloading objects from requester
|
|
1252
|
+
# pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
|
|
1253
|
+
# in the *Amazon S3 Developer Guide*.
|
|
1254
|
+
#
|
|
1255
|
+
#
|
|
1256
|
+
#
|
|
1257
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
|
1258
|
+
# @return [Types::RestoreObjectOutput]
|
|
1259
|
+
def restore_object(options = {})
|
|
1260
|
+
options = options.merge(
|
|
1261
|
+
bucket: @bucket_name,
|
|
1262
|
+
key: @key
|
|
1263
|
+
)
|
|
1264
|
+
resp = @client.restore_object(options)
|
|
1265
|
+
resp.data
|
|
1266
|
+
end
|
|
1267
|
+
|
|
1268
|
+
# @!group Associations
|
|
1269
|
+
|
|
1270
|
+
# @return [ObjectAcl]
|
|
1271
|
+
def acl
|
|
1272
|
+
ObjectAcl.new(
|
|
1273
|
+
bucket_name: @bucket_name,
|
|
1274
|
+
object_key: @key,
|
|
1275
|
+
client: @client
|
|
1276
|
+
)
|
|
1277
|
+
end
|
|
1278
|
+
|
|
1279
|
+
# @return [Bucket]
|
|
1280
|
+
def bucket
|
|
1281
|
+
Bucket.new(
|
|
1282
|
+
name: @bucket_name,
|
|
1283
|
+
client: @client
|
|
1284
|
+
)
|
|
1285
|
+
end
|
|
1286
|
+
|
|
1287
|
+
# @param [String] id
|
|
1288
|
+
# @return [MultipartUpload]
|
|
1289
|
+
def multipart_upload(id)
|
|
1290
|
+
MultipartUpload.new(
|
|
1291
|
+
bucket_name: @bucket_name,
|
|
1292
|
+
object_key: @key,
|
|
1293
|
+
id: id,
|
|
1294
|
+
client: @client
|
|
1295
|
+
)
|
|
1296
|
+
end
|
|
1297
|
+
|
|
1298
|
+
# @param [String] id
|
|
1299
|
+
# @return [ObjectVersion]
|
|
1300
|
+
def version(id)
|
|
1301
|
+
ObjectVersion.new(
|
|
1302
|
+
bucket_name: @bucket_name,
|
|
1303
|
+
object_key: @key,
|
|
1304
|
+
id: id,
|
|
1305
|
+
client: @client
|
|
1306
|
+
)
|
|
1307
|
+
end
|
|
1308
|
+
|
|
1309
|
+
# @deprecated
|
|
1310
|
+
# @api private
|
|
1311
|
+
def identifiers
|
|
1312
|
+
{
|
|
1313
|
+
bucket_name: @bucket_name,
|
|
1314
|
+
key: @key
|
|
1315
|
+
}
|
|
1316
|
+
end
|
|
1317
|
+
deprecated(:identifiers)
|
|
1318
|
+
|
|
1319
|
+
private
|
|
1320
|
+
|
|
1321
|
+
def extract_bucket_name(args, options)
|
|
1322
|
+
value = args[0] || options.delete(:bucket_name)
|
|
1323
|
+
case value
|
|
1324
|
+
when String then value
|
|
1325
|
+
when nil then raise ArgumentError, "missing required option :bucket_name"
|
|
1326
|
+
else
|
|
1327
|
+
msg = "expected :bucket_name to be a String, got #{value.class}"
|
|
1328
|
+
raise ArgumentError, msg
|
|
1329
|
+
end
|
|
1330
|
+
end
|
|
1331
|
+
|
|
1332
|
+
def extract_key(args, options)
|
|
1333
|
+
value = args[1] || options.delete(:key)
|
|
1334
|
+
case value
|
|
1335
|
+
when String then value
|
|
1336
|
+
when nil then raise ArgumentError, "missing required option :key"
|
|
1337
|
+
else
|
|
1338
|
+
msg = "expected :key to be a String, got #{value.class}"
|
|
1339
|
+
raise ArgumentError, msg
|
|
1340
|
+
end
|
|
1341
|
+
end
|
|
1342
|
+
|
|
1343
|
+
def yield_waiter_and_warn(waiter, &block)
|
|
1344
|
+
if !@waiter_block_warned
|
|
1345
|
+
msg = "pass options to configure the waiter; "\
|
|
1346
|
+
"yielding the waiter is deprecated"
|
|
1347
|
+
warn(msg)
|
|
1348
|
+
@waiter_block_warned = true
|
|
1349
|
+
end
|
|
1350
|
+
yield(waiter.waiter)
|
|
1351
|
+
end
|
|
1352
|
+
|
|
1353
|
+
def separate_params_and_options(options)
|
|
1354
|
+
opts = Set.new(
|
|
1355
|
+
[:client, :max_attempts, :delay, :before_attempt, :before_wait]
|
|
1356
|
+
)
|
|
1357
|
+
waiter_opts = {}
|
|
1358
|
+
waiter_params = {}
|
|
1359
|
+
options.each_pair do |key, value|
|
|
1360
|
+
if opts.include?(key)
|
|
1361
|
+
waiter_opts[key] = value
|
|
1362
|
+
else
|
|
1363
|
+
waiter_params[key] = value
|
|
1364
|
+
end
|
|
1365
|
+
end
|
|
1366
|
+
waiter_opts[:client] ||= @client
|
|
1367
|
+
[waiter_opts, waiter_params]
|
|
1368
|
+
end
|
|
1369
|
+
|
|
1370
|
+
class Collection < Aws::Resources::Collection
|
|
1371
|
+
|
|
1372
|
+
# @!group Batch Actions
|
|
1373
|
+
|
|
1374
|
+
# @example Request syntax with placeholder values
|
|
1375
|
+
#
|
|
1376
|
+
# object.batch_delete!({
|
|
1377
|
+
# mfa: "MFA",
|
|
1378
|
+
# request_payer: "requester", # accepts requester
|
|
1379
|
+
# bypass_governance_retention: false,
|
|
1380
|
+
# })
|
|
1381
|
+
# @param options ({})
|
|
1382
|
+
# @option options [String] :mfa
|
|
1383
|
+
# The concatenation of the authentication device's serial number, a
|
|
1384
|
+
# space, and the value that is displayed on your authentication device.
|
|
1385
|
+
# Required to permanently delete a versioned object if versioning is
|
|
1386
|
+
# configured with MFA delete enabled.
|
|
1387
|
+
# @option options [String] :request_payer
|
|
1388
|
+
# Confirms that the requester knows that they will be charged for the
|
|
1389
|
+
# request. Bucket owners need not specify this parameter in their
|
|
1390
|
+
# requests. For information about downloading objects from requester
|
|
1391
|
+
# pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
|
|
1392
|
+
# in the *Amazon S3 Developer Guide*.
|
|
1393
|
+
#
|
|
1394
|
+
#
|
|
1395
|
+
#
|
|
1396
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
|
1397
|
+
# @option options [Boolean] :bypass_governance_retention
|
|
1398
|
+
# Specifies whether you want to delete this object even if it has a
|
|
1399
|
+
# Governance-type Object Lock in place. You must have sufficient
|
|
1400
|
+
# permissions to perform this operation.
|
|
1401
|
+
# @return [void]
|
|
1402
|
+
def batch_delete!(options = {})
|
|
1403
|
+
batch_enum.each do |batch|
|
|
1404
|
+
params = Aws::Util.copy_hash(options)
|
|
1405
|
+
params[:bucket] = batch[0].bucket_name
|
|
1406
|
+
params[:delete] ||= {}
|
|
1407
|
+
params[:delete][:objects] ||= []
|
|
1408
|
+
batch.each do |item|
|
|
1409
|
+
params[:delete][:objects] << {
|
|
1410
|
+
key: item.key
|
|
1411
|
+
}
|
|
1412
|
+
end
|
|
1413
|
+
batch[0].client.delete_objects(params)
|
|
1414
|
+
end
|
|
1415
|
+
nil
|
|
1416
|
+
end
|
|
1417
|
+
|
|
1418
|
+
# @!endgroup
|
|
1419
|
+
|
|
1420
|
+
end
|
|
1421
|
+
end
|
|
1422
|
+
end
|