aws-sdk-s3 1.0.0.rc2 → 1.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
@@ -245,10 +245,11 @@ module Aws
245
245
  # without any errors.
246
246
  #
247
247
  def upload_file(source, options = {})
248
+ uploading_options = options.dup
248
249
  uploader = FileUploader.new(
249
- multipart_threshold: options.delete(:multipart_threshold),
250
+ multipart_threshold: uploading_options.delete(:multipart_threshold),
250
251
  client: client)
251
- uploader.upload(source, options.merge(bucket: bucket_name, key: key))
252
+ uploader.upload(source, uploading_options.merge(bucket: bucket_name, key: key))
252
253
  true
253
254
  end
254
255
 
@@ -1,23 +1,14 @@
1
1
  # WARNING ABOUT GENERATED CODE
2
2
  #
3
- # This file is generated. See the contributing for info on making contributions:
3
+ # This file is generated. See the contributing guide for more information:
4
4
  # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
5
  #
6
6
  # WARNING ABOUT GENERATED CODE
7
7
 
8
- module Aws
9
- module S3
10
- module Errors
8
+ module Aws::S3
9
+ module Errors
11
10
 
12
- extend Aws::Errors::DynamicErrors
11
+ extend Aws::Errors::DynamicErrors
13
12
 
14
- # Raised when calling #load or #data on a resource class that can not be
15
- # loaded. This can happen when:
16
- #
17
- # * A resource class has identifiers, but no data attributes.
18
- # * Resource data is only available when making an API call that
19
- # enumerates all resources of that type.
20
- class ResourceNotLoadable < RuntimeError; end
21
- end
22
13
  end
23
14
  end
@@ -1,287 +1,285 @@
1
1
  # WARNING ABOUT GENERATED CODE
2
2
  #
3
- # This file is generated. See the contributing for info on making contributions:
3
+ # This file is generated. See the contributing guide for more information:
4
4
  # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
5
  #
6
6
  # WARNING ABOUT GENERATED CODE
7
7
 
8
- module Aws
9
- module S3
10
- class MultipartUpload
8
+ module Aws::S3
9
+ class MultipartUpload
11
10
 
12
- extend Aws::Deprecations
11
+ extend Aws::Deprecations
13
12
 
14
- # @overload def initialize(bucket_name, object_key, id, options = {})
15
- # @param [String] bucket_name
16
- # @param [String] object_key
17
- # @param [String] id
18
- # @option options [Client] :client
19
- # @overload def initialize(options = {})
20
- # @option options [required, String] :bucket_name
21
- # @option options [required, String] :object_key
22
- # @option options [required, String] :id
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
- @object_key = extract_object_key(args, options)
28
- @id = extract_id(args, options)
29
- @data = options.delete(:data)
30
- @client = options.delete(:client) || Client.new(options)
31
- end
13
+ # @overload def initialize(bucket_name, object_key, id, options = {})
14
+ # @param [String] bucket_name
15
+ # @param [String] object_key
16
+ # @param [String] id
17
+ # @option options [Client] :client
18
+ # @overload def initialize(options = {})
19
+ # @option options [required, String] :bucket_name
20
+ # @option options [required, String] :object_key
21
+ # @option options [required, String] :id
22
+ # @option options [Client] :client
23
+ def initialize(*args)
24
+ options = Hash === args.last ? args.pop.dup : {}
25
+ @bucket_name = extract_bucket_name(args, options)
26
+ @object_key = extract_object_key(args, options)
27
+ @id = extract_id(args, options)
28
+ @data = options.delete(:data)
29
+ @client = options.delete(:client) || Client.new(options)
30
+ end
32
31
 
33
- # @!group Read-Only Attributes
32
+ # @!group Read-Only Attributes
34
33
 
35
- # @return [String]
36
- def bucket_name
37
- @bucket_name
38
- end
34
+ # @return [String]
35
+ def bucket_name
36
+ @bucket_name
37
+ end
39
38
 
40
- # @return [String]
41
- def object_key
42
- @object_key
43
- end
39
+ # @return [String]
40
+ def object_key
41
+ @object_key
42
+ end
44
43
 
45
- # @return [String]
46
- def id
47
- @id
48
- end
44
+ # @return [String]
45
+ def id
46
+ @id
47
+ end
49
48
 
50
- # Upload ID that identifies the multipart upload.
51
- # @return [String]
52
- def upload_id
53
- data.upload_id
54
- end
49
+ # Upload ID that identifies the multipart upload.
50
+ # @return [String]
51
+ def upload_id
52
+ data.upload_id
53
+ end
55
54
 
56
- # Key of the object for which the multipart upload was initiated.
57
- # @return [String]
58
- def key
59
- data.key
60
- end
55
+ # Key of the object for which the multipart upload was initiated.
56
+ # @return [String]
57
+ def key
58
+ data.key
59
+ end
61
60
 
62
- # Date and time at which the multipart upload was initiated.
63
- # @return [Time]
64
- def initiated
65
- data.initiated
66
- end
61
+ # Date and time at which the multipart upload was initiated.
62
+ # @return [Time]
63
+ def initiated
64
+ data.initiated
65
+ end
67
66
 
68
- # The class of storage used to store the object.
69
- # @return [String]
70
- def storage_class
71
- data.storage_class
72
- end
67
+ # The class of storage used to store the object.
68
+ # @return [String]
69
+ def storage_class
70
+ data.storage_class
71
+ end
73
72
 
74
- # @return [Types::Owner]
75
- def owner
76
- data.owner
77
- end
73
+ # @return [Types::Owner]
74
+ def owner
75
+ data.owner
76
+ end
78
77
 
79
- # Identifies who initiated the multipart upload.
80
- # @return [Types::Initiator]
81
- def initiator
82
- data.initiator
83
- end
78
+ # Identifies who initiated the multipart upload.
79
+ # @return [Types::Initiator]
80
+ def initiator
81
+ data.initiator
82
+ end
84
83
 
85
- # @!endgroup
84
+ # @!endgroup
86
85
 
87
- # @return [Client]
88
- def client
89
- @client
90
- end
86
+ # @return [Client]
87
+ def client
88
+ @client
89
+ end
91
90
 
92
- # @raise [Errors::ResourceNotLoadable]
93
- # @api private
94
- def load
95
- msg = "#load is not implemented, data only available via enumeration"
96
- raise Errors::ResourceNotLoadable, msg
97
- end
98
- alias :reload :load
91
+ # @raise [NotImplementedError]
92
+ # @api private
93
+ def load
94
+ msg = "#load is not implemented, data only available via enumeration"
95
+ raise NotImplementedError, msg
96
+ end
97
+ alias :reload :load
99
98
 
100
- # @raise [Errors::ResourceNotLoadableError] Raises when {#data_loaded?} is `false`.
101
- # @return [Types::MultipartUpload]
102
- # Returns the data for this {MultipartUpload}.
103
- def data
104
- load unless @data
105
- @data
106
- end
99
+ # @raise [NotImplementedError] Raises when {#data_loaded?} is `false`.
100
+ # @return [Types::MultipartUpload]
101
+ # Returns the data for this {MultipartUpload}.
102
+ def data
103
+ load unless @data
104
+ @data
105
+ end
107
106
 
108
- # @return [Boolean]
109
- # Returns `true` if this resource is loaded. Accessing attributes or
110
- # {#data} on an unloaded resource will trigger a call to {#load}.
111
- def data_loaded?
112
- !!@data
113
- end
107
+ # @return [Boolean]
108
+ # Returns `true` if this resource is loaded. Accessing attributes or
109
+ # {#data} on an unloaded resource will trigger a call to {#load}.
110
+ def data_loaded?
111
+ !!@data
112
+ end
114
113
 
115
- # @!group Actions
114
+ # @!group Actions
116
115
 
117
- # @example Request syntax with placeholder values
118
- #
119
- # multipart_upload.abort({
120
- # request_payer: "requester", # accepts requester
121
- # })
122
- # @param [Hash] options ({})
123
- # @option options [String] :request_payer
124
- # Confirms that the requester knows that she or he will be charged for
125
- # the request. Bucket owners need not specify this parameter in their
126
- # requests. Documentation on downloading objects from requester pays
127
- # buckets can be found at
128
- # http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
129
- # @return [Types::AbortMultipartUploadOutput]
130
- def abort(options = {})
131
- options = options.merge(
132
- bucket: @bucket_name,
133
- key: @object_key,
134
- upload_id: @id
135
- )
136
- resp = @client.abort_multipart_upload(options)
137
- resp.data
138
- end
116
+ # @example Request syntax with placeholder values
117
+ #
118
+ # multipart_upload.abort({
119
+ # request_payer: "requester", # accepts requester
120
+ # })
121
+ # @param [Hash] options ({})
122
+ # @option options [String] :request_payer
123
+ # Confirms that the requester knows that she or he will be charged for
124
+ # the request. Bucket owners need not specify this parameter in their
125
+ # requests. Documentation on downloading objects from requester pays
126
+ # buckets can be found at
127
+ # http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
128
+ # @return [Types::AbortMultipartUploadOutput]
129
+ def abort(options = {})
130
+ options = options.merge(
131
+ bucket: @bucket_name,
132
+ key: @object_key,
133
+ upload_id: @id
134
+ )
135
+ resp = @client.abort_multipart_upload(options)
136
+ resp.data
137
+ end
138
+
139
+ # @example Request syntax with placeholder values
140
+ #
141
+ # object = multipart_upload.complete({
142
+ # multipart_upload: {
143
+ # parts: [
144
+ # {
145
+ # etag: "ETag",
146
+ # part_number: 1,
147
+ # },
148
+ # ],
149
+ # },
150
+ # request_payer: "requester", # accepts requester
151
+ # })
152
+ # @param [Hash] options ({})
153
+ # @option options [Types::CompletedMultipartUpload] :multipart_upload
154
+ # @option options [String] :request_payer
155
+ # Confirms that the requester knows that she or he will be charged for
156
+ # the request. Bucket owners need not specify this parameter in their
157
+ # requests. Documentation on downloading objects from requester pays
158
+ # buckets can be found at
159
+ # http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
160
+ # @return [Object]
161
+ def complete(options = {})
162
+ options = options.merge(
163
+ bucket: @bucket_name,
164
+ key: @object_key,
165
+ upload_id: @id
166
+ )
167
+ resp = @client.complete_multipart_upload(options)
168
+ Object.new(
169
+ bucket_name: @bucket_name,
170
+ key: @object_key,
171
+ client: @client
172
+ )
173
+ end
174
+
175
+ # @!group Associations
176
+
177
+ # @return [Object]
178
+ def object
179
+ Object.new(
180
+ bucket_name: @bucket_name,
181
+ key: @object_key,
182
+ client: @client
183
+ )
184
+ end
139
185
 
140
- # @example Request syntax with placeholder values
141
- #
142
- # object = multipart_upload.complete({
143
- # multipart_upload: {
144
- # parts: [
145
- # {
146
- # etag: "ETag",
147
- # part_number: 1,
148
- # },
149
- # ],
150
- # },
151
- # request_payer: "requester", # accepts requester
152
- # })
153
- # @param [Hash] options ({})
154
- # @option options [Types::CompletedMultipartUpload] :multipart_upload
155
- # @option options [String] :request_payer
156
- # Confirms that the requester knows that she or he will be charged for
157
- # the request. Bucket owners need not specify this parameter in their
158
- # requests. Documentation on downloading objects from requester pays
159
- # buckets can be found at
160
- # http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
161
- # @return [Object]
162
- def complete(options = {})
186
+ # @param [String] part_number
187
+ # @return [MultipartUploadPart]
188
+ def part(part_number)
189
+ MultipartUploadPart.new(
190
+ bucket_name: @bucket_name,
191
+ object_key: @object_key,
192
+ multipart_upload_id: @id,
193
+ part_number: part_number,
194
+ client: @client
195
+ )
196
+ end
197
+
198
+ # @example Request syntax with placeholder values
199
+ #
200
+ # parts = multipart_upload.parts({
201
+ # request_payer: "requester", # accepts requester
202
+ # })
203
+ # @param [Hash] options ({})
204
+ # @option options [String] :request_payer
205
+ # Confirms that the requester knows that she or he will be charged for
206
+ # the request. Bucket owners need not specify this parameter in their
207
+ # requests. Documentation on downloading objects from requester pays
208
+ # buckets can be found at
209
+ # http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
210
+ # @return [MultipartUploadPart::Collection]
211
+ def parts(options = {})
212
+ batches = Enumerator.new do |y|
163
213
  options = options.merge(
164
214
  bucket: @bucket_name,
165
215
  key: @object_key,
166
216
  upload_id: @id
167
217
  )
168
- resp = @client.complete_multipart_upload(options)
169
- Object.new(
170
- bucket_name: @bucket_name,
171
- key: @object_key,
172
- client: @client
173
- )
174
- end
175
-
176
- # @!group Associations
177
-
178
- # @return [Object]
179
- def object
180
- Object.new(
181
- bucket_name: @bucket_name,
182
- key: @object_key,
183
- client: @client
184
- )
185
- end
186
-
187
- # @param [String] part_number
188
- # @return [MultipartUploadPart]
189
- def part(part_number)
190
- MultipartUploadPart.new(
191
- bucket_name: @bucket_name,
192
- object_key: @object_key,
193
- multipart_upload_id: @id,
194
- part_number: part_number,
195
- client: @client
196
- )
197
- end
198
-
199
- # @example Request syntax with placeholder values
200
- #
201
- # parts = multipart_upload.parts({
202
- # request_payer: "requester", # accepts requester
203
- # })
204
- # @param [Hash] options ({})
205
- # @option options [String] :request_payer
206
- # Confirms that the requester knows that she or he will be charged for
207
- # the request. Bucket owners need not specify this parameter in their
208
- # requests. Documentation on downloading objects from requester pays
209
- # buckets can be found at
210
- # http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
211
- # @return [MultipartUploadPart::Collection]
212
- def parts(options = {})
213
- batches = Enumerator.new do |y|
214
- options = options.merge(
215
- bucket: @bucket_name,
216
- key: @object_key,
217
- upload_id: @id
218
- )
219
- resp = @client.list_parts(options)
220
- resp.each_page do |page|
221
- batch = []
222
- page.data.parts.each do |p|
223
- batch << MultipartUploadPart.new(
224
- bucket_name: options[:bucket],
225
- object_key: options[:key],
226
- multipart_upload_id: options[:upload_id],
227
- part_number: p.part_number,
228
- data: p,
229
- client: @client
230
- )
231
- end
232
- y.yield(batch)
218
+ resp = @client.list_parts(options)
219
+ resp.each_page do |page|
220
+ batch = []
221
+ page.data.parts.each do |p|
222
+ batch << MultipartUploadPart.new(
223
+ bucket_name: options[:bucket],
224
+ object_key: options[:key],
225
+ multipart_upload_id: options[:upload_id],
226
+ part_number: p.part_number,
227
+ data: p,
228
+ client: @client
229
+ )
233
230
  end
231
+ y.yield(batch)
234
232
  end
235
- MultipartUploadPart::Collection.new(batches)
236
233
  end
234
+ MultipartUploadPart::Collection.new(batches)
235
+ end
237
236
 
238
- # @deprecated
239
- # @api private
240
- def identifiers
241
- {
242
- bucket_name: @bucket_name,
243
- object_key: @object_key,
244
- id: @id
245
- }
246
- end
247
- deprecated(:identifiers)
237
+ # @deprecated
238
+ # @api private
239
+ def identifiers
240
+ {
241
+ bucket_name: @bucket_name,
242
+ object_key: @object_key,
243
+ id: @id
244
+ }
245
+ end
246
+ deprecated(:identifiers)
248
247
 
249
- private
248
+ private
250
249
 
251
- def extract_bucket_name(args, options)
252
- value = args[0] || options.delete(:bucket_name)
253
- case value
254
- when String then value
255
- when nil then raise ArgumentError, "missing required option :bucket_name"
256
- else
257
- msg = "expected :bucket_name to be a String, got #{value.class}"
258
- raise ArgumentError, msg
259
- end
250
+ def extract_bucket_name(args, options)
251
+ value = args[0] || options.delete(:bucket_name)
252
+ case value
253
+ when String then value
254
+ when nil then raise ArgumentError, "missing required option :bucket_name"
255
+ else
256
+ msg = "expected :bucket_name to be a String, got #{value.class}"
257
+ raise ArgumentError, msg
260
258
  end
259
+ end
261
260
 
262
- def extract_object_key(args, options)
263
- value = args[1] || options.delete(:object_key)
264
- case value
265
- when String then value
266
- when nil then raise ArgumentError, "missing required option :object_key"
267
- else
268
- msg = "expected :object_key to be a String, got #{value.class}"
269
- raise ArgumentError, msg
270
- end
261
+ def extract_object_key(args, options)
262
+ value = args[1] || options.delete(:object_key)
263
+ case value
264
+ when String then value
265
+ when nil then raise ArgumentError, "missing required option :object_key"
266
+ else
267
+ msg = "expected :object_key to be a String, got #{value.class}"
268
+ raise ArgumentError, msg
271
269
  end
270
+ end
272
271
 
273
- def extract_id(args, options)
274
- value = args[2] || options.delete(:id)
275
- case value
276
- when String then value
277
- when nil then raise ArgumentError, "missing required option :id"
278
- else
279
- msg = "expected :id to be a String, got #{value.class}"
280
- raise ArgumentError, msg
281
- end
272
+ def extract_id(args, options)
273
+ value = args[2] || options.delete(:id)
274
+ case value
275
+ when String then value
276
+ when nil then raise ArgumentError, "missing required option :id"
277
+ else
278
+ msg = "expected :id to be a String, got #{value.class}"
279
+ raise ArgumentError, msg
282
280
  end
283
-
284
- class Collection < Aws::Resources::Collection; end
285
281
  end
282
+
283
+ class Collection < Aws::Resources::Collection; end
286
284
  end
287
285
  end