aws-sdk-s3 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/aws-sdk-s3.rb +66 -0
- data/lib/aws-sdk-s3/bucket.rb +595 -0
- data/lib/aws-sdk-s3/bucket_acl.rb +168 -0
- data/lib/aws-sdk-s3/bucket_cors.rb +146 -0
- data/lib/aws-sdk-s3/bucket_lifecycle.rb +164 -0
- data/lib/aws-sdk-s3/bucket_logging.rb +142 -0
- data/lib/aws-sdk-s3/bucket_notification.rb +187 -0
- data/lib/aws-sdk-s3/bucket_policy.rb +138 -0
- data/lib/aws-sdk-s3/bucket_region_cache.rb +79 -0
- data/lib/aws-sdk-s3/bucket_request_payment.rb +128 -0
- data/lib/aws-sdk-s3/bucket_tagging.rb +143 -0
- data/lib/aws-sdk-s3/bucket_versioning.rb +188 -0
- data/lib/aws-sdk-s3/bucket_website.rb +177 -0
- data/lib/aws-sdk-s3/client.rb +3171 -0
- data/lib/aws-sdk-s3/client_api.rb +1991 -0
- data/lib/aws-sdk-s3/customizations.rb +29 -0
- data/lib/aws-sdk-s3/customizations/bucket.rb +127 -0
- data/lib/aws-sdk-s3/customizations/multipart_upload.rb +42 -0
- data/lib/aws-sdk-s3/customizations/object.rb +257 -0
- data/lib/aws-sdk-s3/customizations/object_summary.rb +65 -0
- data/lib/aws-sdk-s3/customizations/types/list_object_versions_output.rb +11 -0
- data/lib/aws-sdk-s3/encryption.rb +19 -0
- data/lib/aws-sdk-s3/encryption/client.rb +369 -0
- data/lib/aws-sdk-s3/encryption/decrypt_handler.rb +178 -0
- data/lib/aws-sdk-s3/encryption/default_cipher_provider.rb +63 -0
- data/lib/aws-sdk-s3/encryption/default_key_provider.rb +38 -0
- data/lib/aws-sdk-s3/encryption/encrypt_handler.rb +50 -0
- data/lib/aws-sdk-s3/encryption/errors.rb +13 -0
- data/lib/aws-sdk-s3/encryption/io_auth_decrypter.rb +50 -0
- data/lib/aws-sdk-s3/encryption/io_decrypter.rb +29 -0
- data/lib/aws-sdk-s3/encryption/io_encrypter.rb +69 -0
- data/lib/aws-sdk-s3/encryption/key_provider.rb +29 -0
- data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +71 -0
- data/lib/aws-sdk-s3/encryption/materials.rb +58 -0
- data/lib/aws-sdk-s3/encryption/utils.rb +79 -0
- data/lib/aws-sdk-s3/errors.rb +23 -0
- data/lib/aws-sdk-s3/file_part.rb +75 -0
- data/lib/aws-sdk-s3/file_uploader.rb +58 -0
- data/lib/aws-sdk-s3/legacy_signer.rb +186 -0
- data/lib/aws-sdk-s3/multipart_file_uploader.rb +187 -0
- data/lib/aws-sdk-s3/multipart_upload.rb +287 -0
- data/lib/aws-sdk-s3/multipart_upload_error.rb +16 -0
- data/lib/aws-sdk-s3/multipart_upload_part.rb +314 -0
- data/lib/aws-sdk-s3/object.rb +942 -0
- data/lib/aws-sdk-s3/object_acl.rb +214 -0
- data/lib/aws-sdk-s3/object_copier.rb +99 -0
- data/lib/aws-sdk-s3/object_multipart_copier.rb +179 -0
- data/lib/aws-sdk-s3/object_summary.rb +794 -0
- data/lib/aws-sdk-s3/object_version.rb +406 -0
- data/lib/aws-sdk-s3/plugins/accelerate.rb +92 -0
- data/lib/aws-sdk-s3/plugins/bucket_dns.rb +89 -0
- data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +23 -0
- data/lib/aws-sdk-s3/plugins/dualstack.rb +70 -0
- data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +29 -0
- data/lib/aws-sdk-s3/plugins/get_bucket_location_fix.rb +23 -0
- data/lib/aws-sdk-s3/plugins/http_200_errors.rb +47 -0
- data/lib/aws-sdk-s3/plugins/location_constraint.rb +33 -0
- data/lib/aws-sdk-s3/plugins/md5s.rb +79 -0
- data/lib/aws-sdk-s3/plugins/redirects.rb +41 -0
- data/lib/aws-sdk-s3/plugins/s3_signer.rb +208 -0
- data/lib/aws-sdk-s3/plugins/sse_cpk.rb +68 -0
- data/lib/aws-sdk-s3/plugins/url_encoded_keys.rb +94 -0
- data/lib/aws-sdk-s3/presigned_post.rb +647 -0
- data/lib/aws-sdk-s3/presigner.rb +160 -0
- data/lib/aws-sdk-s3/resource.rb +96 -0
- data/lib/aws-sdk-s3/types.rb +5750 -0
- data/lib/aws-sdk-s3/waiters.rb +178 -0
- metadata +154 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
module Aws
|
2
|
+
module S3
|
3
|
+
class MultipartUploadError < StandardError
|
4
|
+
|
5
|
+
def initialize(message, errors)
|
6
|
+
@errors = errors
|
7
|
+
super(message)
|
8
|
+
end
|
9
|
+
|
10
|
+
# @return [Array<StandardError>] The list of errors encountered
|
11
|
+
# when uploading or aborting the upload.
|
12
|
+
attr_reader :errors
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,314 @@
|
|
1
|
+
# WARNING ABOUT GENERATED CODE
|
2
|
+
#
|
3
|
+
# This file is generated. See the contributing for info on making contributions:
|
4
|
+
# https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
|
5
|
+
#
|
6
|
+
# WARNING ABOUT GENERATED CODE
|
7
|
+
|
8
|
+
module Aws
|
9
|
+
module S3
|
10
|
+
class MultipartUploadPart
|
11
|
+
|
12
|
+
extend Aws::Deprecations
|
13
|
+
|
14
|
+
# @overload def initialize(bucket_name, object_key, multipart_upload_id, part_number, options = {})
|
15
|
+
# @param [String] bucket_name
|
16
|
+
# @param [String] object_key
|
17
|
+
# @param [String] multipart_upload_id
|
18
|
+
# @param [Integer] part_number
|
19
|
+
# @option options [Client] :client
|
20
|
+
# @overload def initialize(options = {})
|
21
|
+
# @option options [required, String] :bucket_name
|
22
|
+
# @option options [required, String] :object_key
|
23
|
+
# @option options [required, String] :multipart_upload_id
|
24
|
+
# @option options [required, Integer] :part_number
|
25
|
+
# @option options [Client] :client
|
26
|
+
def initialize(*args)
|
27
|
+
options = Hash === args.last ? args.pop.dup : {}
|
28
|
+
@bucket_name = extract_bucket_name(args, options)
|
29
|
+
@object_key = extract_object_key(args, options)
|
30
|
+
@multipart_upload_id = extract_multipart_upload_id(args, options)
|
31
|
+
@part_number = extract_part_number(args, options)
|
32
|
+
@data = options.delete(:data)
|
33
|
+
@client = options.delete(:client) || Client.new(options)
|
34
|
+
end
|
35
|
+
|
36
|
+
# @!group Read-Only Attributes
|
37
|
+
|
38
|
+
# @return [String]
|
39
|
+
def bucket_name
|
40
|
+
@bucket_name
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [String]
|
44
|
+
def object_key
|
45
|
+
@object_key
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [String]
|
49
|
+
def multipart_upload_id
|
50
|
+
@multipart_upload_id
|
51
|
+
end
|
52
|
+
|
53
|
+
# @return [Integer]
|
54
|
+
def part_number
|
55
|
+
@part_number
|
56
|
+
end
|
57
|
+
|
58
|
+
# Date and time at which the part was uploaded.
|
59
|
+
# @return [Time]
|
60
|
+
def last_modified
|
61
|
+
data.last_modified
|
62
|
+
end
|
63
|
+
|
64
|
+
# Entity tag returned when the part was uploaded.
|
65
|
+
# @return [String]
|
66
|
+
def etag
|
67
|
+
data.etag
|
68
|
+
end
|
69
|
+
|
70
|
+
# Size of the uploaded part data.
|
71
|
+
# @return [Integer]
|
72
|
+
def size
|
73
|
+
data.size
|
74
|
+
end
|
75
|
+
|
76
|
+
# @!endgroup
|
77
|
+
|
78
|
+
# @return [Client]
|
79
|
+
def client
|
80
|
+
@client
|
81
|
+
end
|
82
|
+
|
83
|
+
# @raise [Errors::ResourceNotLoadable]
|
84
|
+
# @api private
|
85
|
+
def load
|
86
|
+
msg = "#load is not implemented, data only available via enumeration"
|
87
|
+
raise Errors::ResourceNotLoadable, msg
|
88
|
+
end
|
89
|
+
alias :reload :load
|
90
|
+
|
91
|
+
# @raise [Errors::ResourceNotLoadableError] Raises when {#data_loaded?} is `false`.
|
92
|
+
# @return [Types::Part]
|
93
|
+
# Returns the data for this {MultipartUploadPart}.
|
94
|
+
def data
|
95
|
+
load unless @data
|
96
|
+
@data
|
97
|
+
end
|
98
|
+
|
99
|
+
# @return [Boolean]
|
100
|
+
# Returns `true` if this resource is loaded. Accessing attributes or
|
101
|
+
# {#data} on an unloaded resource will trigger a call to {#load}.
|
102
|
+
def data_loaded?
|
103
|
+
!!@data
|
104
|
+
end
|
105
|
+
|
106
|
+
# @!group Actions
|
107
|
+
|
108
|
+
# @example Request syntax with placeholder values
|
109
|
+
#
|
110
|
+
# multipart_upload_part.copy_from({
|
111
|
+
# copy_source: "CopySource", # required
|
112
|
+
# copy_source_if_match: "CopySourceIfMatch",
|
113
|
+
# copy_source_if_modified_since: Time.now,
|
114
|
+
# copy_source_if_none_match: "CopySourceIfNoneMatch",
|
115
|
+
# copy_source_if_unmodified_since: Time.now,
|
116
|
+
# copy_source_range: "CopySourceRange",
|
117
|
+
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
118
|
+
# sse_customer_key: "SSECustomerKey",
|
119
|
+
# sse_customer_key_md5: "SSECustomerKeyMD5",
|
120
|
+
# copy_source_sse_customer_algorithm: "CopySourceSSECustomerAlgorithm",
|
121
|
+
# copy_source_sse_customer_key: "CopySourceSSECustomerKey",
|
122
|
+
# copy_source_sse_customer_key_md5: "CopySourceSSECustomerKeyMD5",
|
123
|
+
# request_payer: "requester", # accepts requester
|
124
|
+
# })
|
125
|
+
# @param [Hash] options ({})
|
126
|
+
# @option options [required, String] :copy_source
|
127
|
+
# The name of the source bucket and key name of the source object,
|
128
|
+
# separated by a slash (/). Must be URL-encoded.
|
129
|
+
# @option options [String] :copy_source_if_match
|
130
|
+
# Copies the object if its entity tag (ETag) matches the specified tag.
|
131
|
+
# @option options [Time,DateTime,Date,Integer,String] :copy_source_if_modified_since
|
132
|
+
# Copies the object if it has been modified since the specified time.
|
133
|
+
# @option options [String] :copy_source_if_none_match
|
134
|
+
# Copies the object if its entity tag (ETag) is different than the
|
135
|
+
# specified ETag.
|
136
|
+
# @option options [Time,DateTime,Date,Integer,String] :copy_source_if_unmodified_since
|
137
|
+
# Copies the object if it hasn't been modified since the specified
|
138
|
+
# time.
|
139
|
+
# @option options [String] :copy_source_range
|
140
|
+
# The range of bytes to copy from the source object. The range value
|
141
|
+
# must use the form bytes=first-last, where the first and last are the
|
142
|
+
# zero-based byte offsets to copy. For example, bytes=0-9 indicates that
|
143
|
+
# you want to copy the first ten bytes of the source. You can copy a
|
144
|
+
# range only if the source object is greater than 5 GB.
|
145
|
+
# @option options [String] :sse_customer_algorithm
|
146
|
+
# Specifies the algorithm to use to when encrypting the object (e.g.,
|
147
|
+
# AES256).
|
148
|
+
# @option options [String] :sse_customer_key
|
149
|
+
# Specifies the customer-provided encryption key for Amazon S3 to use in
|
150
|
+
# encrypting data. This value is used to store the object and then it is
|
151
|
+
# discarded; Amazon does not store the encryption key. The key must be
|
152
|
+
# appropriate for use with the algorithm specified in the
|
153
|
+
# x-amz-server-side-encryption-customer-algorithm header. This must be
|
154
|
+
# the same encryption key specified in the initiate multipart upload
|
155
|
+
# request.
|
156
|
+
# @option options [String] :sse_customer_key_md5
|
157
|
+
# Specifies the 128-bit MD5 digest of the encryption key according to
|
158
|
+
# RFC 1321. Amazon S3 uses this header for a message integrity check to
|
159
|
+
# ensure the encryption key was transmitted without error.
|
160
|
+
# @option options [String] :copy_source_sse_customer_algorithm
|
161
|
+
# Specifies the algorithm to use when decrypting the source object
|
162
|
+
# (e.g., AES256).
|
163
|
+
# @option options [String] :copy_source_sse_customer_key
|
164
|
+
# Specifies the customer-provided encryption key for Amazon S3 to use to
|
165
|
+
# decrypt the source object. The encryption key provided in this header
|
166
|
+
# must be one that was used when the source object was created.
|
167
|
+
# @option options [String] :copy_source_sse_customer_key_md5
|
168
|
+
# Specifies the 128-bit MD5 digest of the encryption key according to
|
169
|
+
# RFC 1321. Amazon S3 uses this header for a message integrity check to
|
170
|
+
# ensure the encryption key was transmitted without error.
|
171
|
+
# @option options [String] :request_payer
|
172
|
+
# Confirms that the requester knows that she or he will be charged for
|
173
|
+
# the request. Bucket owners need not specify this parameter in their
|
174
|
+
# requests. Documentation on downloading objects from requester pays
|
175
|
+
# buckets can be found at
|
176
|
+
# http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
177
|
+
# @return [Types::UploadPartCopyOutput]
|
178
|
+
def copy_from(options = {})
|
179
|
+
options = options.merge(
|
180
|
+
bucket: @bucket_name,
|
181
|
+
key: @object_key,
|
182
|
+
upload_id: @multipart_upload_id,
|
183
|
+
part_number: @part_number
|
184
|
+
)
|
185
|
+
resp = @client.upload_part_copy(options)
|
186
|
+
resp.data
|
187
|
+
end
|
188
|
+
|
189
|
+
# @example Request syntax with placeholder values
|
190
|
+
#
|
191
|
+
# multipart_upload_part.upload({
|
192
|
+
# body: source_file,
|
193
|
+
# content_length: 1,
|
194
|
+
# content_md5: "ContentMD5",
|
195
|
+
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
196
|
+
# sse_customer_key: "SSECustomerKey",
|
197
|
+
# sse_customer_key_md5: "SSECustomerKeyMD5",
|
198
|
+
# request_payer: "requester", # accepts requester
|
199
|
+
# })
|
200
|
+
# @param [Hash] options ({})
|
201
|
+
# @option options [String, IO] :body
|
202
|
+
# Object data.
|
203
|
+
# @option options [Integer] :content_length
|
204
|
+
# Size of the body in bytes. This parameter is useful when the size of
|
205
|
+
# the body cannot be determined automatically.
|
206
|
+
# @option options [String] :content_md5
|
207
|
+
# The base64-encoded 128-bit MD5 digest of the part data.
|
208
|
+
# @option options [String] :sse_customer_algorithm
|
209
|
+
# Specifies the algorithm to use to when encrypting the object (e.g.,
|
210
|
+
# AES256).
|
211
|
+
# @option options [String] :sse_customer_key
|
212
|
+
# Specifies the customer-provided encryption key for Amazon S3 to use in
|
213
|
+
# encrypting data. This value is used to store the object and then it is
|
214
|
+
# discarded; Amazon does not store the encryption key. The key must be
|
215
|
+
# appropriate for use with the algorithm specified in the
|
216
|
+
# x-amz-server-side-encryption-customer-algorithm header. This must be
|
217
|
+
# the same encryption key specified in the initiate multipart upload
|
218
|
+
# request.
|
219
|
+
# @option options [String] :sse_customer_key_md5
|
220
|
+
# Specifies the 128-bit MD5 digest of the encryption key according to
|
221
|
+
# RFC 1321. Amazon S3 uses this header for a message integrity check to
|
222
|
+
# ensure the encryption key was transmitted without error.
|
223
|
+
# @option options [String] :request_payer
|
224
|
+
# Confirms that the requester knows that she or he will be charged for
|
225
|
+
# the request. Bucket owners need not specify this parameter in their
|
226
|
+
# requests. Documentation on downloading objects from requester pays
|
227
|
+
# buckets can be found at
|
228
|
+
# http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
229
|
+
# @return [Types::UploadPartOutput]
|
230
|
+
def upload(options = {})
|
231
|
+
options = options.merge(
|
232
|
+
bucket: @bucket_name,
|
233
|
+
key: @object_key,
|
234
|
+
upload_id: @multipart_upload_id,
|
235
|
+
part_number: @part_number
|
236
|
+
)
|
237
|
+
resp = @client.upload_part(options)
|
238
|
+
resp.data
|
239
|
+
end
|
240
|
+
|
241
|
+
# @!group Associations
|
242
|
+
|
243
|
+
# @return [MultipartUpload]
|
244
|
+
def multipart_upload
|
245
|
+
MultipartUpload.new(
|
246
|
+
bucket_name: @bucket_name,
|
247
|
+
object_key: @object_key,
|
248
|
+
id: @multipart_upload_id,
|
249
|
+
client: @client
|
250
|
+
)
|
251
|
+
end
|
252
|
+
|
253
|
+
# @deprecated
|
254
|
+
# @api private
|
255
|
+
def identifiers
|
256
|
+
{
|
257
|
+
bucket_name: @bucket_name,
|
258
|
+
object_key: @object_key,
|
259
|
+
multipart_upload_id: @multipart_upload_id,
|
260
|
+
part_number: @part_number
|
261
|
+
}
|
262
|
+
end
|
263
|
+
deprecated(:identifiers)
|
264
|
+
|
265
|
+
private
|
266
|
+
|
267
|
+
def extract_bucket_name(args, options)
|
268
|
+
value = args[0] || options.delete(:bucket_name)
|
269
|
+
case value
|
270
|
+
when String then value
|
271
|
+
when nil then raise ArgumentError, "missing required option :bucket_name"
|
272
|
+
else
|
273
|
+
msg = "expected :bucket_name to be a String, got #{value.class}"
|
274
|
+
raise ArgumentError, msg
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
def extract_object_key(args, options)
|
279
|
+
value = args[1] || options.delete(:object_key)
|
280
|
+
case value
|
281
|
+
when String then value
|
282
|
+
when nil then raise ArgumentError, "missing required option :object_key"
|
283
|
+
else
|
284
|
+
msg = "expected :object_key to be a String, got #{value.class}"
|
285
|
+
raise ArgumentError, msg
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
def extract_multipart_upload_id(args, options)
|
290
|
+
value = args[2] || options.delete(:multipart_upload_id)
|
291
|
+
case value
|
292
|
+
when String then value
|
293
|
+
when nil then raise ArgumentError, "missing required option :multipart_upload_id"
|
294
|
+
else
|
295
|
+
msg = "expected :multipart_upload_id to be a String, got #{value.class}"
|
296
|
+
raise ArgumentError, msg
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
def extract_part_number(args, options)
|
301
|
+
value = args[3] || options.delete(:part_number)
|
302
|
+
case value
|
303
|
+
when Integer then value
|
304
|
+
when nil then raise ArgumentError, "missing required option :part_number"
|
305
|
+
else
|
306
|
+
msg = "expected :part_number to be a Integer, got #{value.class}"
|
307
|
+
raise ArgumentError, msg
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
class Collection < Aws::Resources::Collection; end
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|
@@ -0,0 +1,942 @@
|
|
1
|
+
# WARNING ABOUT GENERATED CODE
|
2
|
+
#
|
3
|
+
# This file is generated. See the contributing for info on making contributions:
|
4
|
+
# https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
|
5
|
+
#
|
6
|
+
# WARNING ABOUT GENERATED CODE
|
7
|
+
|
8
|
+
module Aws
|
9
|
+
module S3
|
10
|
+
class Object
|
11
|
+
|
12
|
+
extend Aws::Deprecations
|
13
|
+
|
14
|
+
# @overload def initialize(bucket_name, key, options = {})
|
15
|
+
# @param [String] bucket_name
|
16
|
+
# @param [String] key
|
17
|
+
# @option options [Client] :client
|
18
|
+
# @overload def initialize(options = {})
|
19
|
+
# @option options [required, String] :bucket_name
|
20
|
+
# @option options [required, String] :key
|
21
|
+
# @option options [Client] :client
|
22
|
+
def initialize(*args)
|
23
|
+
options = Hash === args.last ? args.pop.dup : {}
|
24
|
+
@bucket_name = extract_bucket_name(args, options)
|
25
|
+
@key = extract_key(args, options)
|
26
|
+
@data = options.delete(:data)
|
27
|
+
@client = options.delete(:client) || Client.new(options)
|
28
|
+
end
|
29
|
+
|
30
|
+
# @!group Read-Only Attributes
|
31
|
+
|
32
|
+
# @return [String]
|
33
|
+
def bucket_name
|
34
|
+
@bucket_name
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [String]
|
38
|
+
def key
|
39
|
+
@key
|
40
|
+
end
|
41
|
+
|
42
|
+
# Specifies whether the object retrieved was (true) or was not (false) a
|
43
|
+
# Delete Marker. If false, this response header does not appear in the
|
44
|
+
# response.
|
45
|
+
# @return [Boolean]
|
46
|
+
def delete_marker
|
47
|
+
data.delete_marker
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [String]
|
51
|
+
def accept_ranges
|
52
|
+
data.accept_ranges
|
53
|
+
end
|
54
|
+
|
55
|
+
# If the object expiration is configured (see PUT Bucket lifecycle), the
|
56
|
+
# response includes this header. It includes the expiry-date and rule-id
|
57
|
+
# key value pairs providing object expiration information. The value of
|
58
|
+
# the rule-id is URL encoded.
|
59
|
+
# @return [String]
|
60
|
+
def expiration
|
61
|
+
data.expiration
|
62
|
+
end
|
63
|
+
|
64
|
+
# Provides information about object restoration operation and expiration
|
65
|
+
# time of the restored object copy.
|
66
|
+
# @return [String]
|
67
|
+
def restore
|
68
|
+
data.restore
|
69
|
+
end
|
70
|
+
|
71
|
+
# Last modified date of the object
|
72
|
+
# @return [Time]
|
73
|
+
def last_modified
|
74
|
+
data.last_modified
|
75
|
+
end
|
76
|
+
|
77
|
+
# Size of the body in bytes.
|
78
|
+
# @return [Integer]
|
79
|
+
def content_length
|
80
|
+
data.content_length
|
81
|
+
end
|
82
|
+
|
83
|
+
# An ETag is an opaque identifier assigned by a web server to a specific
|
84
|
+
# version of a resource found at a URL
|
85
|
+
# @return [String]
|
86
|
+
def etag
|
87
|
+
data.etag
|
88
|
+
end
|
89
|
+
|
90
|
+
# This is set to the number of metadata entries not returned in
|
91
|
+
# x-amz-meta headers. This can happen if you create metadata using an
|
92
|
+
# API like SOAP that supports more flexible metadata than the REST API.
|
93
|
+
# For example, using SOAP, you can create metadata whose values are not
|
94
|
+
# legal HTTP headers.
|
95
|
+
# @return [Integer]
|
96
|
+
def missing_meta
|
97
|
+
data.missing_meta
|
98
|
+
end
|
99
|
+
|
100
|
+
# Version of the object.
|
101
|
+
# @return [String]
|
102
|
+
def version_id
|
103
|
+
data.version_id
|
104
|
+
end
|
105
|
+
|
106
|
+
# Specifies caching behavior along the request/reply chain.
|
107
|
+
# @return [String]
|
108
|
+
def cache_control
|
109
|
+
data.cache_control
|
110
|
+
end
|
111
|
+
|
112
|
+
# Specifies presentational information for the object.
|
113
|
+
# @return [String]
|
114
|
+
def content_disposition
|
115
|
+
data.content_disposition
|
116
|
+
end
|
117
|
+
|
118
|
+
# Specifies what content encodings have been applied to the object and
|
119
|
+
# thus what decoding mechanisms must be applied to obtain the media-type
|
120
|
+
# referenced by the Content-Type header field.
|
121
|
+
# @return [String]
|
122
|
+
def content_encoding
|
123
|
+
data.content_encoding
|
124
|
+
end
|
125
|
+
|
126
|
+
# The language the content is in.
|
127
|
+
# @return [String]
|
128
|
+
def content_language
|
129
|
+
data.content_language
|
130
|
+
end
|
131
|
+
|
132
|
+
# A standard MIME type describing the format of the object data.
|
133
|
+
# @return [String]
|
134
|
+
def content_type
|
135
|
+
data.content_type
|
136
|
+
end
|
137
|
+
|
138
|
+
# The date and time at which the object is no longer cacheable.
|
139
|
+
# @return [Time]
|
140
|
+
def expires
|
141
|
+
data.expires
|
142
|
+
end
|
143
|
+
|
144
|
+
# @return [String]
|
145
|
+
def expires_string
|
146
|
+
data.expires_string
|
147
|
+
end
|
148
|
+
|
149
|
+
# If the bucket is configured as a website, redirects requests for this
|
150
|
+
# object to another object in the same bucket or to an external URL.
|
151
|
+
# Amazon S3 stores the value of this header in the object metadata.
|
152
|
+
# @return [String]
|
153
|
+
def website_redirect_location
|
154
|
+
data.website_redirect_location
|
155
|
+
end
|
156
|
+
|
157
|
+
# The Server-side encryption algorithm used when storing this object in
|
158
|
+
# S3 (e.g., AES256, aws:kms).
|
159
|
+
# @return [String]
|
160
|
+
def server_side_encryption
|
161
|
+
data.server_side_encryption
|
162
|
+
end
|
163
|
+
|
164
|
+
# A map of metadata to store with the object in S3.
|
165
|
+
# @return [Hash<String,String>]
|
166
|
+
def metadata
|
167
|
+
data.metadata
|
168
|
+
end
|
169
|
+
|
170
|
+
# If server-side encryption with a customer-provided encryption key was
|
171
|
+
# requested, the response will include this header confirming the
|
172
|
+
# encryption algorithm used.
|
173
|
+
# @return [String]
|
174
|
+
def sse_customer_algorithm
|
175
|
+
data.sse_customer_algorithm
|
176
|
+
end
|
177
|
+
|
178
|
+
# If server-side encryption with a customer-provided encryption key was
|
179
|
+
# requested, the response will include this header to provide round trip
|
180
|
+
# message integrity verification of the customer-provided encryption
|
181
|
+
# key.
|
182
|
+
# @return [String]
|
183
|
+
def sse_customer_key_md5
|
184
|
+
data.sse_customer_key_md5
|
185
|
+
end
|
186
|
+
|
187
|
+
# If present, specifies the ID of the AWS Key Management Service (KMS)
|
188
|
+
# master encryption key that was used for the object.
|
189
|
+
# @return [String]
|
190
|
+
def ssekms_key_id
|
191
|
+
data.ssekms_key_id
|
192
|
+
end
|
193
|
+
|
194
|
+
# @return [String]
|
195
|
+
def storage_class
|
196
|
+
data.storage_class
|
197
|
+
end
|
198
|
+
|
199
|
+
# If present, indicates that the requester was successfully charged for
|
200
|
+
# the request.
|
201
|
+
# @return [String]
|
202
|
+
def request_charged
|
203
|
+
data.request_charged
|
204
|
+
end
|
205
|
+
|
206
|
+
# @return [String]
|
207
|
+
def replication_status
|
208
|
+
data.replication_status
|
209
|
+
end
|
210
|
+
|
211
|
+
# The count of parts this object has.
|
212
|
+
# @return [Integer]
|
213
|
+
def parts_count
|
214
|
+
data.parts_count
|
215
|
+
end
|
216
|
+
|
217
|
+
# @!endgroup
|
218
|
+
|
219
|
+
# @return [Client]
|
220
|
+
def client
|
221
|
+
@client
|
222
|
+
end
|
223
|
+
|
224
|
+
# Loads, or reloads {#data} for the current {Object}.
|
225
|
+
# Returns `self` making it possible to chain methods.
|
226
|
+
#
|
227
|
+
# object.reload.data
|
228
|
+
#
|
229
|
+
# @return [self]
|
230
|
+
def load
|
231
|
+
resp = @client.head_object(
|
232
|
+
bucket: @bucket_name,
|
233
|
+
key: @key
|
234
|
+
)
|
235
|
+
@data = resp.data
|
236
|
+
self
|
237
|
+
end
|
238
|
+
alias :reload :load
|
239
|
+
|
240
|
+
# @return [Types::HeadObjectOutput]
|
241
|
+
# Returns the data for this {Object}. Calls
|
242
|
+
# {Client#head_object} if {#data_loaded?} is `false`.
|
243
|
+
def data
|
244
|
+
load unless @data
|
245
|
+
@data
|
246
|
+
end
|
247
|
+
|
248
|
+
# @return [Boolean]
|
249
|
+
# Returns `true` if this resource is loaded. Accessing attributes or
|
250
|
+
# {#data} on an unloaded resource will trigger a call to {#load}.
|
251
|
+
def data_loaded?
|
252
|
+
!!@data
|
253
|
+
end
|
254
|
+
|
255
|
+
# @param [Hash] options ({})
|
256
|
+
# @return [Boolean]
|
257
|
+
# Returns `true` if the Object exists.
|
258
|
+
def exists?(options = {})
|
259
|
+
begin
|
260
|
+
wait_until_exists(options.merge(max_attempts: 1))
|
261
|
+
true
|
262
|
+
rescue Aws::Waiters::Errors::UnexpectedError => e
|
263
|
+
raise e.error
|
264
|
+
rescue Aws::Waiters::Errors::WaiterFailed
|
265
|
+
false
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
# @param [Hash] options ({})
|
270
|
+
# @option options [Integer] :max_attempts (20)
|
271
|
+
# @option options [Float] :delay (5)
|
272
|
+
# @option options [Proc] :before_attempt
|
273
|
+
# @option options [Proc] :before_wait
|
274
|
+
# @return [Object]
|
275
|
+
def wait_until_exists(options = {})
|
276
|
+
options, params = separate_params_and_options(options)
|
277
|
+
waiter = Waiters::ObjectExists.new(options)
|
278
|
+
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
|
279
|
+
waiter.wait(params.merge(bucket: @bucket_name,
|
280
|
+
key: @key))
|
281
|
+
Object.new({
|
282
|
+
bucket_name: @bucket_name,
|
283
|
+
key: @key,
|
284
|
+
client: @client
|
285
|
+
})
|
286
|
+
end
|
287
|
+
|
288
|
+
# @param [Hash] options ({})
|
289
|
+
# @option options [Integer] :max_attempts (20)
|
290
|
+
# @option options [Float] :delay (5)
|
291
|
+
# @option options [Proc] :before_attempt
|
292
|
+
# @option options [Proc] :before_wait
|
293
|
+
# @return [Object]
|
294
|
+
def wait_until_not_exists(options = {})
|
295
|
+
options, params = separate_params_and_options(options)
|
296
|
+
waiter = Waiters::ObjectNotExists.new(options)
|
297
|
+
yield_waiter_and_warn(waiter, &Proc.new) if block_given?
|
298
|
+
waiter.wait(params.merge(bucket: @bucket_name,
|
299
|
+
key: @key))
|
300
|
+
Object.new({
|
301
|
+
bucket_name: @bucket_name,
|
302
|
+
key: @key,
|
303
|
+
client: @client
|
304
|
+
})
|
305
|
+
end
|
306
|
+
|
307
|
+
# @!group Actions
|
308
|
+
|
309
|
+
# @example Request syntax with placeholder values
|
310
|
+
#
|
311
|
+
# object.copy_from({
|
312
|
+
# acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
|
313
|
+
# cache_control: "CacheControl",
|
314
|
+
# content_disposition: "ContentDisposition",
|
315
|
+
# content_encoding: "ContentEncoding",
|
316
|
+
# content_language: "ContentLanguage",
|
317
|
+
# content_type: "ContentType",
|
318
|
+
# copy_source: "CopySource", # required
|
319
|
+
# copy_source_if_match: "CopySourceIfMatch",
|
320
|
+
# copy_source_if_modified_since: Time.now,
|
321
|
+
# copy_source_if_none_match: "CopySourceIfNoneMatch",
|
322
|
+
# copy_source_if_unmodified_since: Time.now,
|
323
|
+
# expires: Time.now,
|
324
|
+
# grant_full_control: "GrantFullControl",
|
325
|
+
# grant_read: "GrantRead",
|
326
|
+
# grant_read_acp: "GrantReadACP",
|
327
|
+
# grant_write_acp: "GrantWriteACP",
|
328
|
+
# metadata: {
|
329
|
+
# "MetadataKey" => "MetadataValue",
|
330
|
+
# },
|
331
|
+
# metadata_directive: "COPY", # accepts COPY, REPLACE
|
332
|
+
# server_side_encryption: "AES256", # accepts AES256, aws:kms
|
333
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA
|
334
|
+
# website_redirect_location: "WebsiteRedirectLocation",
|
335
|
+
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
336
|
+
# sse_customer_key: "SSECustomerKey",
|
337
|
+
# sse_customer_key_md5: "SSECustomerKeyMD5",
|
338
|
+
# ssekms_key_id: "SSEKMSKeyId",
|
339
|
+
# copy_source_sse_customer_algorithm: "CopySourceSSECustomerAlgorithm",
|
340
|
+
# copy_source_sse_customer_key: "CopySourceSSECustomerKey",
|
341
|
+
# copy_source_sse_customer_key_md5: "CopySourceSSECustomerKeyMD5",
|
342
|
+
# request_payer: "requester", # accepts requester
|
343
|
+
# })
|
344
|
+
# @param [Hash] options ({})
|
345
|
+
# @option options [String] :acl
|
346
|
+
# The canned ACL to apply to the object.
|
347
|
+
# @option options [String] :cache_control
|
348
|
+
# Specifies caching behavior along the request/reply chain.
|
349
|
+
# @option options [String] :content_disposition
|
350
|
+
# Specifies presentational information for the object.
|
351
|
+
# @option options [String] :content_encoding
|
352
|
+
# Specifies what content encodings have been applied to the object and
|
353
|
+
# thus what decoding mechanisms must be applied to obtain the media-type
|
354
|
+
# referenced by the Content-Type header field.
|
355
|
+
# @option options [String] :content_language
|
356
|
+
# The language the content is in.
|
357
|
+
# @option options [String] :content_type
|
358
|
+
# A standard MIME type describing the format of the object data.
|
359
|
+
# @option options [required, String] :copy_source
|
360
|
+
# The name of the source bucket and key name of the source object,
|
361
|
+
# separated by a slash (/). Must be URL-encoded.
|
362
|
+
# @option options [String] :copy_source_if_match
|
363
|
+
# Copies the object if its entity tag (ETag) matches the specified tag.
|
364
|
+
# @option options [Time,DateTime,Date,Integer,String] :copy_source_if_modified_since
|
365
|
+
# Copies the object if it has been modified since the specified time.
|
366
|
+
# @option options [String] :copy_source_if_none_match
|
367
|
+
# Copies the object if its entity tag (ETag) is different than the
|
368
|
+
# specified ETag.
|
369
|
+
# @option options [Time,DateTime,Date,Integer,String] :copy_source_if_unmodified_since
|
370
|
+
# Copies the object if it hasn't been modified since the specified
|
371
|
+
# time.
|
372
|
+
# @option options [Time,DateTime,Date,Integer,String] :expires
|
373
|
+
# The date and time at which the object is no longer cacheable.
|
374
|
+
# @option options [String] :grant_full_control
|
375
|
+
# Gives the grantee READ, READ\_ACP, and WRITE\_ACP permissions on the
|
376
|
+
# object.
|
377
|
+
# @option options [String] :grant_read
|
378
|
+
# Allows grantee to read the object data and its metadata.
|
379
|
+
# @option options [String] :grant_read_acp
|
380
|
+
# Allows grantee to read the object ACL.
|
381
|
+
# @option options [String] :grant_write_acp
|
382
|
+
# Allows grantee to write the ACL for the applicable object.
|
383
|
+
# @option options [Hash<String,String>] :metadata
|
384
|
+
# A map of metadata to store with the object in S3.
|
385
|
+
# @option options [String] :metadata_directive
|
386
|
+
# Specifies whether the metadata is copied from the source object or
|
387
|
+
# replaced with metadata provided in the request.
|
388
|
+
# @option options [String] :server_side_encryption
|
389
|
+
# The Server-side encryption algorithm used when storing this object in
|
390
|
+
# S3 (e.g., AES256, aws:kms).
|
391
|
+
# @option options [String] :storage_class
|
392
|
+
# The type of storage to use for the object. Defaults to 'STANDARD'.
|
393
|
+
# @option options [String] :website_redirect_location
|
394
|
+
# If the bucket is configured as a website, redirects requests for this
|
395
|
+
# object to another object in the same bucket or to an external URL.
|
396
|
+
# Amazon S3 stores the value of this header in the object metadata.
|
397
|
+
# @option options [String] :sse_customer_algorithm
|
398
|
+
# Specifies the algorithm to use to when encrypting the object (e.g.,
|
399
|
+
# AES256).
|
400
|
+
# @option options [String] :sse_customer_key
|
401
|
+
# Specifies the customer-provided encryption key for Amazon S3 to use in
|
402
|
+
# encrypting data. This value is used to store the object and then it is
|
403
|
+
# discarded; Amazon does not store the encryption key. The key must be
|
404
|
+
# appropriate for use with the algorithm specified in the
|
405
|
+
# x-amz-server-side-encryption-customer-algorithm header.
|
406
|
+
# @option options [String] :sse_customer_key_md5
|
407
|
+
# Specifies the 128-bit MD5 digest of the encryption key according to
|
408
|
+
# RFC 1321. Amazon S3 uses this header for a message integrity check to
|
409
|
+
# ensure the encryption key was transmitted without error.
|
410
|
+
# @option options [String] :ssekms_key_id
|
411
|
+
# Specifies the AWS KMS key ID to use for object encryption. All GET and
|
412
|
+
# PUT requests for an object protected by AWS KMS will fail if not made
|
413
|
+
# via SSL or using SigV4. Documentation on configuring any of the
|
414
|
+
# officially supported AWS SDKs and CLI can be found at
|
415
|
+
# http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version
|
416
|
+
# @option options [String] :copy_source_sse_customer_algorithm
|
417
|
+
# Specifies the algorithm to use when decrypting the source object
|
418
|
+
# (e.g., AES256).
|
419
|
+
# @option options [String] :copy_source_sse_customer_key
|
420
|
+
# Specifies the customer-provided encryption key for Amazon S3 to use to
|
421
|
+
# decrypt the source object. The encryption key provided in this header
|
422
|
+
# must be one that was used when the source object was created.
|
423
|
+
# @option options [String] :copy_source_sse_customer_key_md5
|
424
|
+
# Specifies the 128-bit MD5 digest of the encryption key according to
|
425
|
+
# RFC 1321. Amazon S3 uses this header for a message integrity check to
|
426
|
+
# ensure the encryption key was transmitted without error.
|
427
|
+
# @option options [String] :request_payer
|
428
|
+
# Confirms that the requester knows that she or he will be charged for
|
429
|
+
# the request. Bucket owners need not specify this parameter in their
|
430
|
+
# requests. Documentation on downloading objects from requester pays
|
431
|
+
# buckets can be found at
|
432
|
+
# http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
433
|
+
# @return [Types::CopyObjectOutput]
|
434
|
+
def copy_from(options = {})
|
435
|
+
options = options.merge(
|
436
|
+
bucket: @bucket_name,
|
437
|
+
key: @key
|
438
|
+
)
|
439
|
+
resp = @client.copy_object(options)
|
440
|
+
resp.data
|
441
|
+
end
|
442
|
+
|
443
|
+
# @example Request syntax with placeholder values
|
444
|
+
#
|
445
|
+
# object.delete({
|
446
|
+
# mfa: "MFA",
|
447
|
+
# version_id: "ObjectVersionId",
|
448
|
+
# request_payer: "requester", # accepts requester
|
449
|
+
# })
|
450
|
+
# @param [Hash] options ({})
|
451
|
+
# @option options [String] :mfa
|
452
|
+
# The concatenation of the authentication device's serial number, a
|
453
|
+
# space, and the value that is displayed on your authentication device.
|
454
|
+
# @option options [String] :version_id
|
455
|
+
# VersionId used to reference a specific version of the object.
|
456
|
+
# @option options [String] :request_payer
|
457
|
+
# Confirms that the requester knows that she or he will be charged for
|
458
|
+
# the request. Bucket owners need not specify this parameter in their
|
459
|
+
# requests. Documentation on downloading objects from requester pays
|
460
|
+
# buckets can be found at
|
461
|
+
# http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
462
|
+
# @return [Types::DeleteObjectOutput]
|
463
|
+
def delete(options = {})
|
464
|
+
options = options.merge(
|
465
|
+
bucket: @bucket_name,
|
466
|
+
key: @key
|
467
|
+
)
|
468
|
+
resp = @client.delete_object(options)
|
469
|
+
resp.data
|
470
|
+
end
|
471
|
+
|
472
|
+
# @example Request syntax with placeholder values
|
473
|
+
#
|
474
|
+
# object.get({
|
475
|
+
# if_match: "IfMatch",
|
476
|
+
# if_modified_since: Time.now,
|
477
|
+
# if_none_match: "IfNoneMatch",
|
478
|
+
# if_unmodified_since: Time.now,
|
479
|
+
# range: "Range",
|
480
|
+
# response_cache_control: "ResponseCacheControl",
|
481
|
+
# response_content_disposition: "ResponseContentDisposition",
|
482
|
+
# response_content_encoding: "ResponseContentEncoding",
|
483
|
+
# response_content_language: "ResponseContentLanguage",
|
484
|
+
# response_content_type: "ResponseContentType",
|
485
|
+
# response_expires: Time.now,
|
486
|
+
# version_id: "ObjectVersionId",
|
487
|
+
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
488
|
+
# sse_customer_key: "SSECustomerKey",
|
489
|
+
# sse_customer_key_md5: "SSECustomerKeyMD5",
|
490
|
+
# request_payer: "requester", # accepts requester
|
491
|
+
# part_number: 1,
|
492
|
+
# })
|
493
|
+
# @param [Hash] options ({})
|
494
|
+
# @option options [String] :if_match
|
495
|
+
# Return the object only if its entity tag (ETag) is the same as the one
|
496
|
+
# specified, otherwise return a 412 (precondition failed).
|
497
|
+
# @option options [Time,DateTime,Date,Integer,String] :if_modified_since
|
498
|
+
# Return the object only if it has been modified since the specified
|
499
|
+
# time, otherwise return a 304 (not modified).
|
500
|
+
# @option options [String] :if_none_match
|
501
|
+
# Return the object only if its entity tag (ETag) is different from the
|
502
|
+
# one specified, otherwise return a 304 (not modified).
|
503
|
+
# @option options [Time,DateTime,Date,Integer,String] :if_unmodified_since
|
504
|
+
# Return the object only if it has not been modified since the specified
|
505
|
+
# time, otherwise return a 412 (precondition failed).
|
506
|
+
# @option options [String] :range
|
507
|
+
# Downloads the specified range bytes of an object. For more information
|
508
|
+
# about the HTTP Range header, go to
|
509
|
+
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.
|
510
|
+
# @option options [String] :response_cache_control
|
511
|
+
# Sets the Cache-Control header of the response.
|
512
|
+
# @option options [String] :response_content_disposition
|
513
|
+
# Sets the Content-Disposition header of the response
|
514
|
+
# @option options [String] :response_content_encoding
|
515
|
+
# Sets the Content-Encoding header of the response.
|
516
|
+
# @option options [String] :response_content_language
|
517
|
+
# Sets the Content-Language header of the response.
|
518
|
+
# @option options [String] :response_content_type
|
519
|
+
# Sets the Content-Type header of the response.
|
520
|
+
# @option options [Time,DateTime,Date,Integer,String] :response_expires
|
521
|
+
# Sets the Expires header of the response.
|
522
|
+
# @option options [String] :version_id
|
523
|
+
# VersionId used to reference a specific version of the object.
|
524
|
+
# @option options [String] :sse_customer_algorithm
|
525
|
+
# Specifies the algorithm to use to when encrypting the object (e.g.,
|
526
|
+
# AES256).
|
527
|
+
# @option options [String] :sse_customer_key
|
528
|
+
# Specifies the customer-provided encryption key for Amazon S3 to use in
|
529
|
+
# encrypting data. This value is used to store the object and then it is
|
530
|
+
# discarded; Amazon does not store the encryption key. The key must be
|
531
|
+
# appropriate for use with the algorithm specified in the
|
532
|
+
# x-amz-server-side-encryption-customer-algorithm header.
|
533
|
+
# @option options [String] :sse_customer_key_md5
|
534
|
+
# Specifies the 128-bit MD5 digest of the encryption key according to
|
535
|
+
# RFC 1321. Amazon S3 uses this header for a message integrity check to
|
536
|
+
# ensure the encryption key was transmitted without error.
|
537
|
+
# @option options [String] :request_payer
|
538
|
+
# Confirms that the requester knows that she or he will be charged for
|
539
|
+
# the request. Bucket owners need not specify this parameter in their
|
540
|
+
# requests. Documentation on downloading objects from requester pays
|
541
|
+
# buckets can be found at
|
542
|
+
# http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
543
|
+
# @option options [Integer] :part_number
|
544
|
+
# Part number of the object being read. This is a positive integer
|
545
|
+
# between 1 and 10,000. Effectively performs a 'ranged' GET request
|
546
|
+
# for the part specified. Useful for downloading just a part of an
|
547
|
+
# object.
|
548
|
+
# @return [Types::GetObjectOutput]
|
549
|
+
def get(options = {})
|
550
|
+
options = options.merge(
|
551
|
+
bucket: @bucket_name,
|
552
|
+
key: @key
|
553
|
+
)
|
554
|
+
resp = @client.get_object(options)
|
555
|
+
resp.data
|
556
|
+
end
|
557
|
+
|
558
|
+
# @example Request syntax with placeholder values
|
559
|
+
#
|
560
|
+
# multipartupload = object.initiate_multipart_upload({
|
561
|
+
# acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
|
562
|
+
# cache_control: "CacheControl",
|
563
|
+
# content_disposition: "ContentDisposition",
|
564
|
+
# content_encoding: "ContentEncoding",
|
565
|
+
# content_language: "ContentLanguage",
|
566
|
+
# content_type: "ContentType",
|
567
|
+
# expires: Time.now,
|
568
|
+
# grant_full_control: "GrantFullControl",
|
569
|
+
# grant_read: "GrantRead",
|
570
|
+
# grant_read_acp: "GrantReadACP",
|
571
|
+
# grant_write_acp: "GrantWriteACP",
|
572
|
+
# metadata: {
|
573
|
+
# "MetadataKey" => "MetadataValue",
|
574
|
+
# },
|
575
|
+
# server_side_encryption: "AES256", # accepts AES256, aws:kms
|
576
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA
|
577
|
+
# website_redirect_location: "WebsiteRedirectLocation",
|
578
|
+
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
579
|
+
# sse_customer_key: "SSECustomerKey",
|
580
|
+
# sse_customer_key_md5: "SSECustomerKeyMD5",
|
581
|
+
# ssekms_key_id: "SSEKMSKeyId",
|
582
|
+
# request_payer: "requester", # accepts requester
|
583
|
+
# })
|
584
|
+
# @param [Hash] options ({})
|
585
|
+
# @option options [String] :acl
|
586
|
+
# The canned ACL to apply to the object.
|
587
|
+
# @option options [String] :cache_control
|
588
|
+
# Specifies caching behavior along the request/reply chain.
|
589
|
+
# @option options [String] :content_disposition
|
590
|
+
# Specifies presentational information for the object.
|
591
|
+
# @option options [String] :content_encoding
|
592
|
+
# Specifies what content encodings have been applied to the object and
|
593
|
+
# thus what decoding mechanisms must be applied to obtain the media-type
|
594
|
+
# referenced by the Content-Type header field.
|
595
|
+
# @option options [String] :content_language
|
596
|
+
# The language the content is in.
|
597
|
+
# @option options [String] :content_type
|
598
|
+
# A standard MIME type describing the format of the object data.
|
599
|
+
# @option options [Time,DateTime,Date,Integer,String] :expires
|
600
|
+
# The date and time at which the object is no longer cacheable.
|
601
|
+
# @option options [String] :grant_full_control
|
602
|
+
# Gives the grantee READ, READ\_ACP, and WRITE\_ACP permissions on the
|
603
|
+
# object.
|
604
|
+
# @option options [String] :grant_read
|
605
|
+
# Allows grantee to read the object data and its metadata.
|
606
|
+
# @option options [String] :grant_read_acp
|
607
|
+
# Allows grantee to read the object ACL.
|
608
|
+
# @option options [String] :grant_write_acp
|
609
|
+
# Allows grantee to write the ACL for the applicable object.
|
610
|
+
# @option options [Hash<String,String>] :metadata
|
611
|
+
# A map of metadata to store with the object in S3.
|
612
|
+
# @option options [String] :server_side_encryption
|
613
|
+
# The Server-side encryption algorithm used when storing this object in
|
614
|
+
# S3 (e.g., AES256, aws:kms).
|
615
|
+
# @option options [String] :storage_class
|
616
|
+
# The type of storage to use for the object. Defaults to 'STANDARD'.
|
617
|
+
# @option options [String] :website_redirect_location
|
618
|
+
# If the bucket is configured as a website, redirects requests for this
|
619
|
+
# object to another object in the same bucket or to an external URL.
|
620
|
+
# Amazon S3 stores the value of this header in the object metadata.
|
621
|
+
# @option options [String] :sse_customer_algorithm
|
622
|
+
# Specifies the algorithm to use to when encrypting the object (e.g.,
|
623
|
+
# AES256).
|
624
|
+
# @option options [String] :sse_customer_key
|
625
|
+
# Specifies the customer-provided encryption key for Amazon S3 to use in
|
626
|
+
# encrypting data. This value is used to store the object and then it is
|
627
|
+
# discarded; Amazon does not store the encryption key. The key must be
|
628
|
+
# appropriate for use with the algorithm specified in the
|
629
|
+
# x-amz-server-side-encryption-customer-algorithm header.
|
630
|
+
# @option options [String] :sse_customer_key_md5
|
631
|
+
# Specifies the 128-bit MD5 digest of the encryption key according to
|
632
|
+
# RFC 1321. Amazon S3 uses this header for a message integrity check to
|
633
|
+
# ensure the encryption key was transmitted without error.
|
634
|
+
# @option options [String] :ssekms_key_id
|
635
|
+
# Specifies the AWS KMS key ID to use for object encryption. All GET and
|
636
|
+
# PUT requests for an object protected by AWS KMS will fail if not made
|
637
|
+
# via SSL or using SigV4. Documentation on configuring any of the
|
638
|
+
# officially supported AWS SDKs and CLI can be found at
|
639
|
+
# http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version
|
640
|
+
# @option options [String] :request_payer
|
641
|
+
# Confirms that the requester knows that she or he will be charged for
|
642
|
+
# the request. Bucket owners need not specify this parameter in their
|
643
|
+
# requests. Documentation on downloading objects from requester pays
|
644
|
+
# buckets can be found at
|
645
|
+
# http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
646
|
+
# @return [MultipartUpload]
|
647
|
+
def initiate_multipart_upload(options = {})
|
648
|
+
options = options.merge(
|
649
|
+
bucket: @bucket_name,
|
650
|
+
key: @key
|
651
|
+
)
|
652
|
+
resp = @client.create_multipart_upload(options)
|
653
|
+
MultipartUpload.new(
|
654
|
+
bucket_name: @bucket_name,
|
655
|
+
object_key: @key,
|
656
|
+
id: resp.data.upload_id,
|
657
|
+
client: @client
|
658
|
+
)
|
659
|
+
end
|
660
|
+
|
661
|
+
# @example Request syntax with placeholder values
|
662
|
+
#
|
663
|
+
# object.put({
|
664
|
+
# acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
|
665
|
+
# body: source_file,
|
666
|
+
# cache_control: "CacheControl",
|
667
|
+
# content_disposition: "ContentDisposition",
|
668
|
+
# content_encoding: "ContentEncoding",
|
669
|
+
# content_language: "ContentLanguage",
|
670
|
+
# content_length: 1,
|
671
|
+
# content_md5: "ContentMD5",
|
672
|
+
# content_type: "ContentType",
|
673
|
+
# expires: Time.now,
|
674
|
+
# grant_full_control: "GrantFullControl",
|
675
|
+
# grant_read: "GrantRead",
|
676
|
+
# grant_read_acp: "GrantReadACP",
|
677
|
+
# grant_write_acp: "GrantWriteACP",
|
678
|
+
# metadata: {
|
679
|
+
# "MetadataKey" => "MetadataValue",
|
680
|
+
# },
|
681
|
+
# server_side_encryption: "AES256", # accepts AES256, aws:kms
|
682
|
+
# storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA
|
683
|
+
# website_redirect_location: "WebsiteRedirectLocation",
|
684
|
+
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
685
|
+
# sse_customer_key: "SSECustomerKey",
|
686
|
+
# sse_customer_key_md5: "SSECustomerKeyMD5",
|
687
|
+
# ssekms_key_id: "SSEKMSKeyId",
|
688
|
+
# request_payer: "requester", # accepts requester
|
689
|
+
# })
|
690
|
+
# @param [Hash] options ({})
|
691
|
+
# @option options [String] :acl
|
692
|
+
# The canned ACL to apply to the object.
|
693
|
+
# @option options [String, IO] :body
|
694
|
+
# Object data.
|
695
|
+
# @option options [String] :cache_control
|
696
|
+
# Specifies caching behavior along the request/reply chain.
|
697
|
+
# @option options [String] :content_disposition
|
698
|
+
# Specifies presentational information for the object.
|
699
|
+
# @option options [String] :content_encoding
|
700
|
+
# Specifies what content encodings have been applied to the object and
|
701
|
+
# thus what decoding mechanisms must be applied to obtain the media-type
|
702
|
+
# referenced by the Content-Type header field.
|
703
|
+
# @option options [String] :content_language
|
704
|
+
# The language the content is in.
|
705
|
+
# @option options [Integer] :content_length
|
706
|
+
# Size of the body in bytes. This parameter is useful when the size of
|
707
|
+
# the body cannot be determined automatically.
|
708
|
+
# @option options [String] :content_md5
|
709
|
+
# The base64-encoded 128-bit MD5 digest of the part data.
|
710
|
+
# @option options [String] :content_type
|
711
|
+
# A standard MIME type describing the format of the object data.
|
712
|
+
# @option options [Time,DateTime,Date,Integer,String] :expires
|
713
|
+
# The date and time at which the object is no longer cacheable.
|
714
|
+
# @option options [String] :grant_full_control
|
715
|
+
# Gives the grantee READ, READ\_ACP, and WRITE\_ACP permissions on the
|
716
|
+
# object.
|
717
|
+
# @option options [String] :grant_read
|
718
|
+
# Allows grantee to read the object data and its metadata.
|
719
|
+
# @option options [String] :grant_read_acp
|
720
|
+
# Allows grantee to read the object ACL.
|
721
|
+
# @option options [String] :grant_write_acp
|
722
|
+
# Allows grantee to write the ACL for the applicable object.
|
723
|
+
# @option options [Hash<String,String>] :metadata
|
724
|
+
# A map of metadata to store with the object in S3.
|
725
|
+
# @option options [String] :server_side_encryption
|
726
|
+
# The Server-side encryption algorithm used when storing this object in
|
727
|
+
# S3 (e.g., AES256, aws:kms).
|
728
|
+
# @option options [String] :storage_class
|
729
|
+
# The type of storage to use for the object. Defaults to 'STANDARD'.
|
730
|
+
# @option options [String] :website_redirect_location
|
731
|
+
# If the bucket is configured as a website, redirects requests for this
|
732
|
+
# object to another object in the same bucket or to an external URL.
|
733
|
+
# Amazon S3 stores the value of this header in the object metadata.
|
734
|
+
# @option options [String] :sse_customer_algorithm
|
735
|
+
# Specifies the algorithm to use to when encrypting the object (e.g.,
|
736
|
+
# AES256).
|
737
|
+
# @option options [String] :sse_customer_key
|
738
|
+
# Specifies the customer-provided encryption key for Amazon S3 to use in
|
739
|
+
# encrypting data. This value is used to store the object and then it is
|
740
|
+
# discarded; Amazon does not store the encryption key. The key must be
|
741
|
+
# appropriate for use with the algorithm specified in the
|
742
|
+
# x-amz-server-side-encryption-customer-algorithm header.
|
743
|
+
# @option options [String] :sse_customer_key_md5
|
744
|
+
# Specifies the 128-bit MD5 digest of the encryption key according to
|
745
|
+
# RFC 1321. Amazon S3 uses this header for a message integrity check to
|
746
|
+
# ensure the encryption key was transmitted without error.
|
747
|
+
# @option options [String] :ssekms_key_id
|
748
|
+
# Specifies the AWS KMS key ID to use for object encryption. All GET and
|
749
|
+
# PUT requests for an object protected by AWS KMS will fail if not made
|
750
|
+
# via SSL or using SigV4. Documentation on configuring any of the
|
751
|
+
# officially supported AWS SDKs and CLI can be found at
|
752
|
+
# http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version
|
753
|
+
# @option options [String] :request_payer
|
754
|
+
# Confirms that the requester knows that she or he will be charged for
|
755
|
+
# the request. Bucket owners need not specify this parameter in their
|
756
|
+
# requests. Documentation on downloading objects from requester pays
|
757
|
+
# buckets can be found at
|
758
|
+
# http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
759
|
+
# @return [Types::PutObjectOutput]
|
760
|
+
def put(options = {})
|
761
|
+
options = options.merge(
|
762
|
+
bucket: @bucket_name,
|
763
|
+
key: @key
|
764
|
+
)
|
765
|
+
resp = @client.put_object(options)
|
766
|
+
resp.data
|
767
|
+
end
|
768
|
+
|
769
|
+
# @example Request syntax with placeholder values
|
770
|
+
#
|
771
|
+
# object.restore_object({
|
772
|
+
# version_id: "ObjectVersionId",
|
773
|
+
# restore_request: {
|
774
|
+
# days: 1, # required
|
775
|
+
# glacier_job_parameters: {
|
776
|
+
# tier: "Standard", # required, accepts Standard, Bulk, Expedited
|
777
|
+
# },
|
778
|
+
# },
|
779
|
+
# request_payer: "requester", # accepts requester
|
780
|
+
# })
|
781
|
+
# @param [Hash] options ({})
|
782
|
+
# @option options [String] :version_id
|
783
|
+
# @option options [Types::RestoreRequest] :restore_request
|
784
|
+
# @option options [String] :request_payer
|
785
|
+
# Confirms that the requester knows that she or he will be charged for
|
786
|
+
# the request. Bucket owners need not specify this parameter in their
|
787
|
+
# requests. Documentation on downloading objects from requester pays
|
788
|
+
# buckets can be found at
|
789
|
+
# http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
790
|
+
# @return [Types::RestoreObjectOutput]
|
791
|
+
def restore_object(options = {})
|
792
|
+
options = options.merge(
|
793
|
+
bucket: @bucket_name,
|
794
|
+
key: @key
|
795
|
+
)
|
796
|
+
resp = @client.restore_object(options)
|
797
|
+
resp.data
|
798
|
+
end
|
799
|
+
|
800
|
+
# @!group Associations
|
801
|
+
|
802
|
+
# @return [ObjectAcl]
|
803
|
+
def acl
|
804
|
+
ObjectAcl.new(
|
805
|
+
bucket_name: @bucket_name,
|
806
|
+
object_key: @key,
|
807
|
+
client: @client
|
808
|
+
)
|
809
|
+
end
|
810
|
+
|
811
|
+
# @return [Bucket]
|
812
|
+
def bucket
|
813
|
+
Bucket.new(
|
814
|
+
name: @bucket_name,
|
815
|
+
client: @client
|
816
|
+
)
|
817
|
+
end
|
818
|
+
|
819
|
+
# @param [String] id
|
820
|
+
# @return [MultipartUpload]
|
821
|
+
def multipart_upload(id)
|
822
|
+
MultipartUpload.new(
|
823
|
+
bucket_name: @bucket_name,
|
824
|
+
object_key: @key,
|
825
|
+
id: id,
|
826
|
+
client: @client
|
827
|
+
)
|
828
|
+
end
|
829
|
+
|
830
|
+
# @param [String] id
|
831
|
+
# @return [ObjectVersion]
|
832
|
+
def version(id)
|
833
|
+
ObjectVersion.new(
|
834
|
+
bucket_name: @bucket_name,
|
835
|
+
object_key: @key,
|
836
|
+
id: id,
|
837
|
+
client: @client
|
838
|
+
)
|
839
|
+
end
|
840
|
+
|
841
|
+
# @deprecated
|
842
|
+
# @api private
|
843
|
+
def identifiers
|
844
|
+
{
|
845
|
+
bucket_name: @bucket_name,
|
846
|
+
key: @key
|
847
|
+
}
|
848
|
+
end
|
849
|
+
deprecated(:identifiers)
|
850
|
+
|
851
|
+
private
|
852
|
+
|
853
|
+
def extract_bucket_name(args, options)
|
854
|
+
value = args[0] || options.delete(:bucket_name)
|
855
|
+
case value
|
856
|
+
when String then value
|
857
|
+
when nil then raise ArgumentError, "missing required option :bucket_name"
|
858
|
+
else
|
859
|
+
msg = "expected :bucket_name to be a String, got #{value.class}"
|
860
|
+
raise ArgumentError, msg
|
861
|
+
end
|
862
|
+
end
|
863
|
+
|
864
|
+
def extract_key(args, options)
|
865
|
+
value = args[1] || options.delete(:key)
|
866
|
+
case value
|
867
|
+
when String then value
|
868
|
+
when nil then raise ArgumentError, "missing required option :key"
|
869
|
+
else
|
870
|
+
msg = "expected :key to be a String, got #{value.class}"
|
871
|
+
raise ArgumentError, msg
|
872
|
+
end
|
873
|
+
end
|
874
|
+
|
875
|
+
def yield_waiter_and_warn(waiter, &block)
|
876
|
+
if !@waiter_block_warned
|
877
|
+
msg = "pass options to configure the waiter; "
|
878
|
+
msg << "yielding the waiter is deprecated"
|
879
|
+
warn(msg)
|
880
|
+
@waiter_block_warned = true
|
881
|
+
end
|
882
|
+
yield(waiter.waiter)
|
883
|
+
end
|
884
|
+
|
885
|
+
def separate_params_and_options(options)
|
886
|
+
opts = Set.new([:client, :max_attempts, :delay, :before_attempt, :before_wait])
|
887
|
+
waiter_opts = {}
|
888
|
+
waiter_params = {}
|
889
|
+
options.each_pair do |key, value|
|
890
|
+
if opts.include?(key)
|
891
|
+
waiter_opts[key] = value
|
892
|
+
else
|
893
|
+
waiter_params[key] = value
|
894
|
+
end
|
895
|
+
end
|
896
|
+
waiter_opts[:client] ||= @client
|
897
|
+
[waiter_opts, waiter_params]
|
898
|
+
end
|
899
|
+
|
900
|
+
class Collection < Aws::Resources::Collection
|
901
|
+
|
902
|
+
# @!group Batch Actions
|
903
|
+
|
904
|
+
# @example Request syntax with placeholder values
|
905
|
+
#
|
906
|
+
# object.batch_delete!({
|
907
|
+
# mfa: "MFA",
|
908
|
+
# request_payer: "requester", # accepts requester
|
909
|
+
# })
|
910
|
+
# @param options ({})
|
911
|
+
# @option options [String] :mfa
|
912
|
+
# The concatenation of the authentication device's serial number, a
|
913
|
+
# space, and the value that is displayed on your authentication device.
|
914
|
+
# @option options [String] :request_payer
|
915
|
+
# Confirms that the requester knows that she or he will be charged for
|
916
|
+
# the request. Bucket owners need not specify this parameter in their
|
917
|
+
# requests. Documentation on downloading objects from requester pays
|
918
|
+
# buckets can be found at
|
919
|
+
# http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
|
920
|
+
# @return [void]
|
921
|
+
def batch_delete!(options = {})
|
922
|
+
batch_enum.each do |batch|
|
923
|
+
params = Aws::Util.copy_hash(options)
|
924
|
+
params[:bucket] = batch[0].bucket_name
|
925
|
+
params[:delete] ||= {}
|
926
|
+
params[:delete][:objects] ||= []
|
927
|
+
batch.each do |item|
|
928
|
+
params[:delete][:objects] << {
|
929
|
+
key: item.key
|
930
|
+
}
|
931
|
+
end
|
932
|
+
batch[0].client.delete_objects(params)
|
933
|
+
end
|
934
|
+
nil
|
935
|
+
end
|
936
|
+
|
937
|
+
# @!endgroup
|
938
|
+
|
939
|
+
end
|
940
|
+
end
|
941
|
+
end
|
942
|
+
end
|