s33r 0.4.1 → 0.4.2
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.
- data/examples/cli/simple.rb +17 -0
- data/examples/fores33r/app/controllers/browser_controller.rb +32 -8
- data/examples/fores33r/app/views/browser/_create_bucket.rhtml +6 -0
- data/examples/fores33r/app/views/browser/_upload.rhtml +5 -0
- data/examples/fores33r/app/views/browser/index.rhtml +1 -8
- data/examples/fores33r/app/views/browser/plain_bucket.rhtml +3 -0
- data/examples/fores33r/app/views/browser/s3_index.rhtml +9 -0
- data/examples/fores33r/app/views/browser/show_bucket.rhtml +6 -8
- data/examples/fores33r/app/views/layouts/application.rhtml +2 -0
- data/examples/fores33r/app/views/layouts/s3_layout.rhtml +14 -0
- data/examples/fores33r/config/environment.rb +1 -1
- data/examples/fores33r/config/routes.rb +2 -0
- data/examples/fores33r/public/stylesheets/core.css +2 -2
- data/html/classes/Net/HTTPResponse.html +3 -0
- data/html/classes/S33r.html +127 -116
- data/html/classes/S33r/BucketListing.html +119 -94
- data/html/classes/S33r/Client.html +602 -536
- data/html/classes/S33r/LoggingResource.html +3 -3
- data/html/classes/S33r/NamedBucket.html +235 -191
- data/html/classes/S33r/OrderlyXmlMarkup.html +7 -7
- data/html/classes/S33r/S33rException.html +1 -0
- data/html/classes/S33r/S33rException/TryingToPutEmptyResource.html +117 -0
- data/html/classes/S33r/S3ACL/ACLDoc.html +94 -94
- data/html/classes/S33r/S3ACL/AmazonCustomer.html +5 -5
- data/html/classes/S33r/S3ACL/CanonicalUser.html +12 -12
- data/html/classes/S33r/S3ACL/Grant.html +64 -64
- data/html/classes/S33r/S3ACL/Grantee.html +36 -36
- data/html/classes/S33r/S3ACL/Group.html +8 -8
- data/html/classes/S33r/S3Object.html +387 -79
- data/html/classes/XML.html +15 -15
- data/html/created.rid +1 -1
- data/html/files/CHANGELOG.html +7 -1
- data/html/files/MIT-LICENSE.html +1 -1
- data/html/files/README_txt.html +3 -7
- data/html/files/lib/s33r/bucket_listing_rb.html +1 -9
- data/html/files/lib/s33r/builder_rb.html +1 -1
- data/html/files/lib/s33r/client_rb.html +1 -1
- data/html/files/lib/s33r/core_rb.html +1 -2
- data/html/files/lib/s33r/libxml_extensions_rb.html +1 -7
- data/html/files/lib/s33r/libxml_loader_rb.html +109 -0
- data/html/files/lib/s33r/logging_rb.html +1 -2
- data/html/files/lib/s33r/mimetypes_rb.html +1 -1
- data/html/files/lib/s33r/named_bucket_rb.html +1 -1
- data/html/files/lib/s33r/s33r_exception_rb.html +1 -1
- data/html/files/lib/s33r/s33r_http_rb.html +1 -1
- data/html/files/lib/s33r/s3_acl_rb.html +1 -2
- data/html/files/lib/s33r/s3_obj_rb.html +108 -0
- data/html/files/lib/s33r/sync_rb.html +1 -1
- data/html/files/lib/s33r_rb.html +1 -1
- data/html/fr_class_index.html +1 -0
- data/html/fr_file_index.html +2 -0
- data/html/fr_method_index.html +80 -71
- data/lib/s33r/bucket_listing.rb +30 -55
- data/lib/s33r/client.rb +70 -28
- data/lib/s33r/core.rb +9 -4
- data/lib/s33r/libxml_extensions.rb +2 -0
- data/lib/s33r/libxml_loader.rb +6 -0
- data/lib/s33r/logging.rb +3 -3
- data/lib/s33r/named_bucket.rb +33 -15
- data/lib/s33r/s33r_exception.rb +4 -0
- data/lib/s33r/s33r_http.rb +1 -1
- data/lib/s33r/s3_acl.rb +3 -2
- data/lib/s33r/s3_obj.rb +186 -0
- data/test/cases/spec_bucket_listing.rb +9 -33
- data/test/cases/spec_s3_object.rb +35 -0
- data/test/files/suspect_bucket_listing.xml +19 -0
- metadata +94 -89
- data/examples/fores33r/log/development.log +0 -5960
- data/examples/fores33r/log/production.log +0 -0
- data/examples/fores33r/log/server.log +0 -0
- data/examples/fores33r/log/test.log +0 -0
- data/examples/fores33r/tmp/sessions/ruby_sess.2ea325f604aa5fb9 +0 -0
- data/examples/fores33r/tmp/sessions/ruby_sess.39d37e054d21d545 +0 -0
- data/examples/fores33r/tmp/sessions/ruby_sess.acf71fc73aa74983 +0 -0
- data/examples/fores33r/tmp/sessions/ruby_sess.c1697b7d6670f3cd +0 -0
@@ -164,10 +164,10 @@ contain a <a href="CanonicalUser.html">CanonicalUser</a> grant.
|
|
164
164
|
onclick="toggleCode('M000078-source');return false;">[Source]</a></p>
|
165
165
|
<div class="method-source-code" id="M000078-source">
|
166
166
|
<pre>
|
167
|
-
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line
|
168
|
-
|
169
|
-
|
170
|
-
|
167
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line 181</span>
|
168
|
+
181: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Grant</span>.<span class="ruby-identifier">for_amazon_customer</span>(<span class="ruby-identifier">email_address</span>, <span class="ruby-identifier">permission</span>)
|
169
|
+
182: <span class="ruby-constant">Grant</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">AmazonCustomer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">email_address</span>), <span class="ruby-identifier">permission</span>)
|
170
|
+
183: <span class="ruby-keyword kw">end</span>
|
171
171
|
</pre>
|
172
172
|
</div>
|
173
173
|
</div>
|
@@ -187,10 +187,10 @@ contain a <a href="CanonicalUser.html">CanonicalUser</a> grant.
|
|
187
187
|
onclick="toggleCode('M000079-source');return false;">[Source]</a></p>
|
188
188
|
<div class="method-source-code" id="M000079-source">
|
189
189
|
<pre>
|
190
|
-
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line
|
191
|
-
|
192
|
-
|
193
|
-
|
190
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line 185</span>
|
191
|
+
185: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Grant</span>.<span class="ruby-identifier">for_canonical_user</span>(<span class="ruby-identifier">id</span>, <span class="ruby-identifier">display_name</span>, <span class="ruby-identifier">permission</span>)
|
192
|
+
186: <span class="ruby-constant">Grant</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">CanonicalUser</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">id</span>, <span class="ruby-identifier">display_name</span>), <span class="ruby-identifier">permission</span>)
|
193
|
+
187: <span class="ruby-keyword kw">end</span>
|
194
194
|
</pre>
|
195
195
|
</div>
|
196
196
|
</div>
|
@@ -210,10 +210,10 @@ contain a <a href="CanonicalUser.html">CanonicalUser</a> grant.
|
|
210
210
|
onclick="toggleCode('M000080-source');return false;">[Source]</a></p>
|
211
211
|
<div class="method-source-code" id="M000080-source">
|
212
212
|
<pre>
|
213
|
-
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line
|
214
|
-
|
215
|
-
|
216
|
-
|
213
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line 189</span>
|
214
|
+
189: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Grant</span>.<span class="ruby-identifier">for_group</span>(<span class="ruby-identifier">group_type</span>, <span class="ruby-identifier">permission</span>)
|
215
|
+
190: <span class="ruby-constant">Grant</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Group</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">group_type</span>), <span class="ruby-identifier">permission</span>)
|
216
|
+
191: <span class="ruby-keyword kw">end</span>
|
217
217
|
</pre>
|
218
218
|
</div>
|
219
219
|
</div>
|
@@ -241,11 +241,11 @@ instances.
|
|
241
241
|
onclick="toggleCode('M000082-source');return false;">[Source]</a></p>
|
242
242
|
<div class="method-source-code" id="M000082-source">
|
243
243
|
<pre>
|
244
|
-
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
244
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line 203</span>
|
245
|
+
203: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Grant</span>.<span class="ruby-identifier">log_target_grants</span>
|
246
|
+
204: <span class="ruby-identifier">log_delivery_group</span> = <span class="ruby-constant">Group</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">:log_delivery</span>)
|
247
|
+
205: [<span class="ruby-constant">Grant</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">log_delivery_group</span>, <span class="ruby-identifier">:read_acl</span>), <span class="ruby-constant">Grant</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">log_delivery_group</span>, <span class="ruby-identifier">:write</span>)]
|
248
|
+
206: <span class="ruby-keyword kw">end</span>
|
249
249
|
</pre>
|
250
250
|
</div>
|
251
251
|
</div>
|
@@ -269,16 +269,16 @@ string
|
|
269
269
|
onclick="toggleCode('M000077-source');return false;">[Source]</a></p>
|
270
270
|
<div class="method-source-code" id="M000077-source">
|
271
271
|
<pre>
|
272
|
-
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
272
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line 167</span>
|
273
|
+
167: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">grantee</span>, <span class="ruby-identifier">permission</span>)
|
274
|
+
168: <span class="ruby-ivar">@grantee</span> = <span class="ruby-identifier">grantee</span>
|
275
|
+
169: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">permission</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
|
276
|
+
170: <span class="ruby-ivar">@permission</span> = <span class="ruby-identifier">permission</span>
|
277
|
+
171: <span class="ruby-keyword kw">else</span>
|
278
|
+
172: <span class="ruby-ivar">@permission</span> = <span class="ruby-constant">PERMISSIONS</span>[<span class="ruby-identifier">permission</span>]
|
279
|
+
173: <span class="ruby-keyword kw">end</span>
|
280
|
+
174: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidPermission</span>, <span class="ruby-node">"Permission #{permission.to_s} is not a valid permission specifier"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@permission</span>.<span class="ruby-identifier">nil?</span>
|
281
|
+
175: <span class="ruby-keyword kw">end</span>
|
282
282
|
</pre>
|
283
283
|
</div>
|
284
284
|
</div>
|
@@ -302,10 +302,10 @@ to the AllUsers group type.
|
|
302
302
|
onclick="toggleCode('M000081-source');return false;">[Source]</a></p>
|
303
303
|
<div class="method-source-code" id="M000081-source">
|
304
304
|
<pre>
|
305
|
-
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line
|
306
|
-
|
307
|
-
|
308
|
-
|
305
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line 195</span>
|
306
|
+
195: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Grant</span>.<span class="ruby-identifier">public_read_grant</span>
|
307
|
+
196: <span class="ruby-constant">Grant</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Group</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">:all_users</span>), <span class="ruby-identifier">:read</span>)
|
308
|
+
197: <span class="ruby-keyword kw">end</span>
|
309
309
|
</pre>
|
310
310
|
</div>
|
311
311
|
</div>
|
@@ -327,16 +327,16 @@ to the AllUsers group type.
|
|
327
327
|
onclick="toggleCode('M000084-source');return false;">[Source]</a></p>
|
328
328
|
<div class="method-source-code" id="M000084-source">
|
329
329
|
<pre>
|
330
|
-
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
330
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line 232</span>
|
331
|
+
232: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">==</span>(<span class="ruby-identifier">obj</span>)
|
332
|
+
233: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">obj</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Grant</span>)
|
333
|
+
234: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
334
|
+
235: <span class="ruby-keyword kw">end</span>
|
335
|
+
236: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">permission</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">permission</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">grantee</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">grantee</span>
|
336
|
+
237: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
337
|
+
238: <span class="ruby-keyword kw">end</span>
|
338
|
+
239: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
|
339
|
+
240: <span class="ruby-keyword kw">end</span>
|
340
340
|
</pre>
|
341
341
|
</div>
|
342
342
|
</div>
|
@@ -360,29 +360,29 @@ href="../../XML.html">XML</a> fragment.
|
|
360
360
|
onclick="toggleCode('M000083-source');return false;">[Source]</a></p>
|
361
361
|
<div class="method-source-code" id="M000083-source">
|
362
362
|
<pre>
|
363
|
-
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
363
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line 209</span>
|
364
|
+
209: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_xml</span>
|
365
|
+
210: <span class="ruby-identifier">xml_str</span> = <span class="ruby-value str">""</span>
|
366
|
+
211: <span class="ruby-identifier">xml</span> = <span class="ruby-constant">S33r</span><span class="ruby-operator">::</span><span class="ruby-constant">OrderlyXmlMarkup</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">:target</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">xml_str</span>, <span class="ruby-identifier">:indent</span> =<span class="ruby-operator">></span> <span class="ruby-value">0</span>)
|
367
|
+
212:
|
368
|
+
213: <span class="ruby-comment cmt"># <Grant> element.</span>
|
369
|
+
214: <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Grant</span> {
|
370
|
+
215: <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Grantee</span>({<span class="ruby-node">"xmlns:#{NAMESPACE}"</span> =<span class="ruby-operator">></span> <span class="ruby-constant">NAMESPACE_URI</span>, <span class="ruby-value str">"xsi:type"</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@grantee</span>.<span class="ruby-identifier">grantee_type</span>}) {
|
371
|
+
216: <span class="ruby-keyword kw">case</span> <span class="ruby-ivar">@grantee</span>.<span class="ruby-identifier">grantee_type</span>
|
372
|
+
217: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">GRANTEE_TYPES</span>[<span class="ruby-identifier">:amazon_customer</span>]
|
373
|
+
218: <span class="ruby-identifier">xml</span>.<span class="ruby-constant">EmailAddress</span> <span class="ruby-ivar">@grantee</span>.<span class="ruby-identifier">email_address</span>
|
374
|
+
219: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">GRANTEE_TYPES</span>[<span class="ruby-identifier">:canonical_user</span>]
|
375
|
+
220: <span class="ruby-identifier">xml</span>.<span class="ruby-constant">ID</span> <span class="ruby-ivar">@grantee</span>.<span class="ruby-identifier">user_id</span>
|
376
|
+
221: <span class="ruby-identifier">xml</span>.<span class="ruby-constant">DisplayName</span> <span class="ruby-ivar">@grantee</span>.<span class="ruby-identifier">display_name</span>
|
377
|
+
222: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">GRANTEE_TYPES</span>[<span class="ruby-identifier">:group</span>]
|
378
|
+
223: <span class="ruby-identifier">xml</span>.<span class="ruby-constant">URI</span> <span class="ruby-constant">GROUP_ACL_URI_BASE</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@grantee</span>.<span class="ruby-identifier">group_type</span>
|
379
|
+
224: <span class="ruby-keyword kw">end</span>
|
380
|
+
225: }
|
381
|
+
226: <span class="ruby-identifier">xml</span>.<span class="ruby-constant">Permission</span> <span class="ruby-ivar">@permission</span>
|
382
|
+
227: }
|
383
|
+
228:
|
384
|
+
229: <span class="ruby-identifier">xml_str</span>
|
385
|
+
230: <span class="ruby-keyword kw">end</span>
|
386
386
|
</pre>
|
387
387
|
</div>
|
388
388
|
</div>
|
@@ -143,25 +143,25 @@ Abstract representation of an S3 <a href="Grantee.html">Grantee</a>.
|
|
143
143
|
onclick="toggleCode('M000076-source');return false;">[Source]</a></p>
|
144
144
|
<div class="method-source-code" id="M000076-source">
|
145
145
|
<pre>
|
146
|
-
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
146
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line 265</span>
|
147
|
+
265: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">from_xml</span>(<span class="ruby-identifier">grantee_xml</span>)
|
148
|
+
266: <span class="ruby-identifier">grantee_type</span> = <span class="ruby-identifier">grantee_xml</span>[<span class="ruby-value str">'type'</span>]
|
149
|
+
267:
|
150
|
+
268: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">grantee_type</span>
|
151
|
+
269: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">GRANTEE_TYPES</span>[<span class="ruby-identifier">:amazon_customer</span>]
|
152
|
+
270: <span class="ruby-constant">AmazonCustomer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">grantee_xml</span>.<span class="ruby-identifier">xget</span>(<span class="ruby-value str">'EmailAddress'</span>))
|
153
|
+
271: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">GRANTEE_TYPES</span>[<span class="ruby-identifier">:canonical_user</span>]
|
154
|
+
272: <span class="ruby-constant">CanonicalUser</span>.<span class="ruby-identifier">from_xml</span>(<span class="ruby-identifier">grantee_xml</span>)
|
155
|
+
273: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">GRANTEE_TYPES</span>[<span class="ruby-identifier">:group</span>]
|
156
|
+
274: <span class="ruby-identifier">uri</span> = <span class="ruby-identifier">grantee_xml</span>.<span class="ruby-identifier">xget</span>(<span class="ruby-value str">'URI'</span>)
|
157
|
+
275: <span class="ruby-comment cmt"># last part of the path is the group type</span>
|
158
|
+
276: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-node">/#{GROUP_ACL_URI_BASE}/</span>, <span class="ruby-value str">''</span>)
|
159
|
+
277:
|
160
|
+
278: <span class="ruby-identifier">group_type</span> = <span class="ruby-identifier">:all_users</span>
|
161
|
+
279: <span class="ruby-constant">S3_GROUP_TYPES</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">group_type</span> = <span class="ruby-identifier">k</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">path</span> }
|
162
|
+
280: <span class="ruby-constant">Group</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">group_type</span>)
|
163
|
+
281: <span class="ruby-keyword kw">end</span>
|
164
|
+
282: <span class="ruby-keyword kw">end</span>
|
165
165
|
</pre>
|
166
166
|
</div>
|
167
167
|
</div>
|
@@ -183,19 +183,19 @@ Abstract representation of an S3 <a href="Grantee.html">Grantee</a>.
|
|
183
183
|
onclick="toggleCode('M000074-source');return false;">[Source]</a></p>
|
184
184
|
<div class="method-source-code" id="M000074-source">
|
185
185
|
<pre>
|
186
|
-
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
186
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line 248</span>
|
187
|
+
248: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">==</span>(<span class="ruby-identifier">obj</span>)
|
188
|
+
249: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">obj</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Grantee</span>)
|
189
|
+
250: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
190
|
+
251: <span class="ruby-keyword kw">end</span>
|
191
|
+
252: <span class="ruby-identifier">instance_variables</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">var</span><span class="ruby-operator">|</span>
|
192
|
+
253: <span class="ruby-identifier">method_name</span> = <span class="ruby-identifier">var</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/^@/</span>, <span class="ruby-value str">''</span>)
|
193
|
+
254: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">method_name</span>) <span class="ruby-operator">!=</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">method_name</span>)
|
194
|
+
255: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
195
|
+
256: <span class="ruby-keyword kw">end</span>
|
196
|
+
257: <span class="ruby-keyword kw">end</span>
|
197
|
+
258: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
|
198
|
+
259: <span class="ruby-keyword kw">end</span>
|
199
199
|
</pre>
|
200
200
|
</div>
|
201
201
|
</div>
|
@@ -215,10 +215,10 @@ Abstract representation of an S3 <a href="Grantee.html">Grantee</a>.
|
|
215
215
|
onclick="toggleCode('M000075-source');return false;">[Source]</a></p>
|
216
216
|
<div class="method-source-code" id="M000075-source">
|
217
217
|
<pre>
|
218
|
-
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line
|
219
|
-
|
220
|
-
|
221
|
-
|
218
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line 261</span>
|
219
|
+
261: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
220
|
+
262: <span class="ruby-keyword kw">nil</span>
|
221
|
+
263: <span class="ruby-keyword kw">end</span>
|
222
222
|
</pre>
|
223
223
|
</div>
|
224
224
|
</div>
|
@@ -150,14 +150,14 @@ Amazon group types.
|
|
150
150
|
onclick="toggleCode('M000060-source');return false;">[Source]</a></p>
|
151
151
|
<div class="method-source-code" id="M000060-source">
|
152
152
|
<pre>
|
153
|
-
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
153
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_acl.rb, line 328</span>
|
154
|
+
328: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">group_type</span>)
|
155
|
+
329: <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">S3_GROUP_TYPES</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">group_type</span>)
|
156
|
+
330: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidS3GroupType</span>, <span class="ruby-value str">'No such group type #{group_type}'</span>
|
157
|
+
331: <span class="ruby-keyword kw">end</span>
|
158
|
+
332: <span class="ruby-ivar">@group_type</span> = <span class="ruby-constant">S3_GROUP_TYPES</span>[<span class="ruby-identifier">group_type</span>]
|
159
|
+
333: <span class="ruby-ivar">@grantee_type</span> = <span class="ruby-constant">GRANTEE_TYPES</span>[<span class="ruby-identifier">:group</span>]
|
160
|
+
334: <span class="ruby-keyword kw">end</span>
|
161
161
|
</pre>
|
162
162
|
</div>
|
163
163
|
</div>
|
@@ -55,8 +55,8 @@
|
|
55
55
|
<tr class="top-aligned-row">
|
56
56
|
<td><strong>In:</strong></td>
|
57
57
|
<td>
|
58
|
-
<a href="../../files/lib/s33r/
|
59
|
-
lib/s33r/
|
58
|
+
<a href="../../files/lib/s33r/s3_obj_rb.html">
|
59
|
+
lib/s33r/s3_obj.rb
|
60
60
|
</a>
|
61
61
|
<br />
|
62
62
|
</td>
|
@@ -78,12 +78,6 @@
|
|
78
78
|
|
79
79
|
<div id="contextContent">
|
80
80
|
|
81
|
-
<div id="description">
|
82
|
-
<p>
|
83
|
-
Representation of an object stored in a bucket.
|
84
|
-
</p>
|
85
|
-
|
86
|
-
</div>
|
87
81
|
|
88
82
|
|
89
83
|
</div>
|
@@ -92,10 +86,17 @@ Representation of an object stored in a bucket.
|
|
92
86
|
<h3 class="section-bar">Methods</h3>
|
93
87
|
|
94
88
|
<div class="name-list">
|
95
|
-
<a href="#
|
89
|
+
<a href="#M000096">delete</a>
|
90
|
+
<a href="#M000089">from_file</a>
|
91
|
+
<a href="#M000093">from_response</a>
|
92
|
+
<a href="#M000091">from_xml_node</a>
|
93
|
+
<a href="#M000090">from_xml_string</a>
|
94
|
+
<a href="#M000095">load</a>
|
96
95
|
<a href="#M000087">new</a>
|
97
|
-
<a href="#
|
98
|
-
<a href="#
|
96
|
+
<a href="#M000094">parse_response</a>
|
97
|
+
<a href="#M000092">parse_xml_node</a>
|
98
|
+
<a href="#M000097">save</a>
|
99
|
+
<a href="#M000088">set_properties</a>
|
99
100
|
</div>
|
100
101
|
</div>
|
101
102
|
|
@@ -115,44 +116,63 @@ Representation of an object stored in a bucket.
|
|
115
116
|
|
116
117
|
<div class="name-list">
|
117
118
|
<table>
|
119
|
+
<tr class="top-aligned-row context-row">
|
120
|
+
<td class="context-item-name">content_type</td>
|
121
|
+
<td class="context-item-value"> [RW] </td>
|
122
|
+
<td class="context-item-desc"></td>
|
123
|
+
</tr>
|
118
124
|
<tr class="top-aligned-row context-row">
|
119
125
|
<td class="context-item-name">etag</td>
|
120
|
-
<td class="context-item-value"> [
|
126
|
+
<td class="context-item-value"> [RW] </td>
|
121
127
|
<td class="context-item-desc"></td>
|
122
128
|
</tr>
|
123
129
|
<tr class="top-aligned-row context-row">
|
124
130
|
<td class="context-item-name">key</td>
|
125
|
-
<td class="context-item-value"> [
|
131
|
+
<td class="context-item-value"> [RW] </td>
|
126
132
|
<td class="context-item-desc"></td>
|
127
133
|
</tr>
|
128
134
|
<tr class="top-aligned-row context-row">
|
129
135
|
<td class="context-item-name">last_modified</td>
|
130
|
-
<td class="context-item-value"> [
|
136
|
+
<td class="context-item-value"> [RW] </td>
|
131
137
|
<td class="context-item-desc"></td>
|
132
138
|
</tr>
|
133
139
|
<tr class="top-aligned-row context-row">
|
134
|
-
<td class="context-item-name">
|
135
|
-
<td class="context-item-value"> [
|
140
|
+
<td class="context-item-name">meta</td>
|
141
|
+
<td class="context-item-value"> [RW] </td>
|
142
|
+
<td class="context-item-desc">
|
143
|
+
Metadata set by x-amz-meta- style headers. Note that the bit after
|
144
|
+
x-amz-meta- is stored for each key, rather than the full key.
|
145
|
+
|
146
|
+
</td>
|
147
|
+
</tr>
|
148
|
+
<tr class="top-aligned-row context-row">
|
149
|
+
<td class="context-item-name">mime_type</td>
|
150
|
+
<td class="context-item-value"> [RW] </td>
|
136
151
|
<td class="context-item-desc"></td>
|
137
152
|
</tr>
|
138
153
|
<tr class="top-aligned-row context-row">
|
139
154
|
<td class="context-item-name">named_bucket</td>
|
140
|
-
<td class="context-item-value"> [
|
155
|
+
<td class="context-item-value"> [RW] </td>
|
141
156
|
<td class="context-item-desc"></td>
|
142
157
|
</tr>
|
143
158
|
<tr class="top-aligned-row context-row">
|
144
159
|
<td class="context-item-name">owner</td>
|
145
|
-
<td class="context-item-value"> [
|
160
|
+
<td class="context-item-value"> [RW] </td>
|
146
161
|
<td class="context-item-desc"></td>
|
147
162
|
</tr>
|
148
163
|
<tr class="top-aligned-row context-row">
|
149
164
|
<td class="context-item-name">size</td>
|
150
|
-
<td class="context-item-value"> [
|
165
|
+
<td class="context-item-value"> [RW] </td>
|
151
166
|
<td class="context-item-desc"></td>
|
152
167
|
</tr>
|
153
168
|
<tr class="top-aligned-row context-row">
|
154
169
|
<td class="context-item-name">storage_class</td>
|
155
|
-
<td class="context-item-value"> [
|
170
|
+
<td class="context-item-value"> [RW] </td>
|
171
|
+
<td class="context-item-desc"></td>
|
172
|
+
</tr>
|
173
|
+
<tr class="top-aligned-row context-row">
|
174
|
+
<td class="context-item-name">value</td>
|
175
|
+
<td class="context-item-value"> [RW] </td>
|
156
176
|
<td class="context-item-desc"></td>
|
157
177
|
</tr>
|
158
178
|
</table>
|
@@ -165,28 +185,261 @@ Representation of an object stored in a bucket.
|
|
165
185
|
<div id="methods">
|
166
186
|
<h3 class="section-bar">Public Class methods</h3>
|
167
187
|
|
188
|
+
<div id="method-M000089" class="method-detail">
|
189
|
+
<a name="M000089"></a>
|
190
|
+
|
191
|
+
<div class="method-heading">
|
192
|
+
<a href="#M000089" class="method-signature">
|
193
|
+
<span class="method-name">from_file</span><span class="method-args">(key, filename)</span>
|
194
|
+
</a>
|
195
|
+
</div>
|
196
|
+
|
197
|
+
<div class="method-description">
|
198
|
+
<p>
|
199
|
+
To create an object which reads the content in from a file; this is not
|
200
|
+
very efficient - it’s actually better to use <a
|
201
|
+
href="NamedBucket.html#M000111">NamedBucket.put_file</a>, as this will
|
202
|
+
stream out of a file to S3, rather than load the file in memory first.
|
203
|
+
</p>
|
204
|
+
<p><a class="source-toggle" href="#"
|
205
|
+
onclick="toggleCode('M000089-source');return false;">[Source]</a></p>
|
206
|
+
<div class="method-source-code" id="M000089-source">
|
207
|
+
<pre>
|
208
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 43</span>
|
209
|
+
43: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">from_file</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">filename</span>)
|
210
|
+
44: <span class="ruby-identifier">mime_type</span> = <span class="ruby-identifier">guess_mime_type</span>(<span class="ruby-identifier">filename</span>)
|
211
|
+
45: <span class="ruby-identifier">content_type</span> = <span class="ruby-identifier">mime_type</span>.<span class="ruby-identifier">simplified</span>
|
212
|
+
46: <span class="ruby-identifier">value</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">filename</span>).<span class="ruby-identifier">read</span>
|
213
|
+
47: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">key</span>, { <span class="ruby-identifier">:content_type</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">content_type</span> }, {}, <span class="ruby-identifier">value</span>)
|
214
|
+
48: <span class="ruby-keyword kw">end</span>
|
215
|
+
</pre>
|
216
|
+
</div>
|
217
|
+
</div>
|
218
|
+
</div>
|
219
|
+
|
220
|
+
<div id="method-M000093" class="method-detail">
|
221
|
+
<a name="M000093"></a>
|
222
|
+
|
223
|
+
<div class="method-heading">
|
224
|
+
<a href="#M000093" class="method-signature">
|
225
|
+
<span class="method-name">from_response</span><span class="method-args">(key, resp)</span>
|
226
|
+
</a>
|
227
|
+
</div>
|
228
|
+
|
229
|
+
<div class="method-description">
|
230
|
+
<p>
|
231
|
+
Create a new instance from a HTTP response. This is useful if you do a GET
|
232
|
+
for a resource key and want to convert the response into an object; NB the
|
233
|
+
response doesn’t necessarily contain all the metadata you might want
|
234
|
+
- you need to do a HEAD for that.
|
235
|
+
</p>
|
236
|
+
<p>
|
237
|
+
<tt>key</tt> is the key for the resource (not part of the response).
|
238
|
+
</p>
|
239
|
+
<p>
|
240
|
+
Note that if the resp returns nil, a blank object is created.
|
241
|
+
</p>
|
242
|
+
<p><a class="source-toggle" href="#"
|
243
|
+
onclick="toggleCode('M000093-source');return false;">[Source]</a></p>
|
244
|
+
<div class="method-source-code" id="M000093-source">
|
245
|
+
<pre>
|
246
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 93</span>
|
247
|
+
93: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">from_response</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">resp</span>)
|
248
|
+
94: <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse_response</span>(<span class="ruby-identifier">resp</span>)
|
249
|
+
95: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>
|
250
|
+
96: <span class="ruby-identifier">metadata</span>, <span class="ruby-identifier">amz_meta</span>, <span class="ruby-identifier">value</span> = <span class="ruby-identifier">result</span>
|
251
|
+
97: <span class="ruby-keyword kw">else</span>
|
252
|
+
98: <span class="ruby-identifier">metadata</span> = {}
|
253
|
+
99: <span class="ruby-identifier">amz_meta</span> = {}
|
254
|
+
100: <span class="ruby-identifier">value</span> = <span class="ruby-keyword kw">nil</span>
|
255
|
+
101: <span class="ruby-keyword kw">end</span>
|
256
|
+
102: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">metadata</span>, <span class="ruby-identifier">amz_meta</span>, <span class="ruby-identifier">value</span>)
|
257
|
+
103: <span class="ruby-keyword kw">end</span>
|
258
|
+
</pre>
|
259
|
+
</div>
|
260
|
+
</div>
|
261
|
+
</div>
|
262
|
+
|
263
|
+
<div id="method-M000091" class="method-detail">
|
264
|
+
<a name="M000091"></a>
|
265
|
+
|
266
|
+
<div class="method-heading">
|
267
|
+
<a href="#M000091" class="method-signature">
|
268
|
+
<span class="method-name">from_xml_node</span><span class="method-args">(doc)</span>
|
269
|
+
</a>
|
270
|
+
</div>
|
271
|
+
|
272
|
+
<div class="method-description">
|
273
|
+
<p>
|
274
|
+
Create a new instance from an <a href="../XML.html">XML</a> document.
|
275
|
+
</p>
|
276
|
+
<p><a class="source-toggle" href="#"
|
277
|
+
onclick="toggleCode('M000091-source');return false;">[Source]</a></p>
|
278
|
+
<div class="method-source-code" id="M000091-source">
|
279
|
+
<pre>
|
280
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 59</span>
|
281
|
+
59: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">from_xml_node</span>(<span class="ruby-identifier">doc</span>)
|
282
|
+
60: <span class="ruby-identifier">metadata</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse_xml_node</span>(<span class="ruby-identifier">doc</span>)
|
283
|
+
61: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:key</span>], <span class="ruby-identifier">metadata</span>)
|
284
|
+
62: <span class="ruby-keyword kw">end</span>
|
285
|
+
</pre>
|
286
|
+
</div>
|
287
|
+
</div>
|
288
|
+
</div>
|
289
|
+
|
290
|
+
<div id="method-M000090" class="method-detail">
|
291
|
+
<a name="M000090"></a>
|
292
|
+
|
293
|
+
<div class="method-heading">
|
294
|
+
<a href="#M000090" class="method-signature">
|
295
|
+
<span class="method-name">from_xml_string</span><span class="method-args">(xml_str)</span>
|
296
|
+
</a>
|
297
|
+
</div>
|
298
|
+
|
299
|
+
<div class="method-description">
|
300
|
+
<p>
|
301
|
+
Set properties of the object from an <a href="../XML.html">XML</a> string.
|
302
|
+
</p>
|
303
|
+
<p>
|
304
|
+
<tt>xml_str</tt> should be a string representing a full <a
|
305
|
+
href="../XML.html">XML</a> document, containing a <Contents> element
|
306
|
+
as its root element.
|
307
|
+
</p>
|
308
|
+
<p><a class="source-toggle" href="#"
|
309
|
+
onclick="toggleCode('M000090-source');return false;">[Source]</a></p>
|
310
|
+
<div class="method-source-code" id="M000090-source">
|
311
|
+
<pre>
|
312
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 54</span>
|
313
|
+
54: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">from_xml_string</span>(<span class="ruby-identifier">xml_str</span>)
|
314
|
+
55: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">from_xml_node</span>(<span class="ruby-constant">XML</span>.<span class="ruby-identifier">get_xml_doc</span>(<span class="ruby-identifier">xml_str</span>))
|
315
|
+
56: <span class="ruby-keyword kw">end</span>
|
316
|
+
</pre>
|
317
|
+
</div>
|
318
|
+
</div>
|
319
|
+
</div>
|
320
|
+
|
168
321
|
<div id="method-M000087" class="method-detail">
|
169
322
|
<a name="M000087"></a>
|
170
323
|
|
171
324
|
<div class="method-heading">
|
172
325
|
<a href="#M000087" class="method-signature">
|
173
|
-
<span class="method-name">new</span><span class="method-args">(
|
326
|
+
<span class="method-name">new</span><span class="method-args">(key, metadata={}, amz_meta={}, value=nil)</span>
|
174
327
|
</a>
|
175
328
|
</div>
|
176
329
|
|
177
330
|
<div class="method-description">
|
178
|
-
<p>
|
179
|
-
Create from a node.
|
180
|
-
</p>
|
181
331
|
<p><a class="source-toggle" href="#"
|
182
332
|
onclick="toggleCode('M000087-source');return false;">[Source]</a></p>
|
183
333
|
<div class="method-source-code" id="M000087-source">
|
184
334
|
<pre>
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
335
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 13</span>
|
336
|
+
13: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">metadata</span>={}, <span class="ruby-identifier">amz_meta</span>={}, <span class="ruby-identifier">value</span>=<span class="ruby-keyword kw">nil</span>)
|
337
|
+
14: <span class="ruby-ivar">@key</span> = <span class="ruby-identifier">key</span>
|
338
|
+
15: <span class="ruby-ivar">@meta</span> = <span class="ruby-identifier">amz_meta</span>
|
339
|
+
16: <span class="ruby-ivar">@value</span> = <span class="ruby-identifier">value</span>
|
340
|
+
17: <span class="ruby-identifier">set_properties</span>(<span class="ruby-identifier">metadata</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">metadata</span>.<span class="ruby-identifier">empty?</span>
|
341
|
+
18: <span class="ruby-keyword kw">end</span>
|
342
|
+
</pre>
|
343
|
+
</div>
|
344
|
+
</div>
|
345
|
+
</div>
|
346
|
+
|
347
|
+
<div id="method-M000094" class="method-detail">
|
348
|
+
<a name="M000094"></a>
|
349
|
+
|
350
|
+
<div class="method-heading">
|
351
|
+
<a href="#M000094" class="method-signature">
|
352
|
+
<span class="method-name">parse_response</span><span class="method-args">(resp)</span>
|
353
|
+
</a>
|
354
|
+
</div>
|
355
|
+
|
356
|
+
<div class="method-description">
|
357
|
+
<p>
|
358
|
+
Parse the response returned by GET on a resource key within a bucket.
|
359
|
+
</p>
|
360
|
+
<p>
|
361
|
+
<tt>resp</tt> is a <a href="../Net/HTTPResponse.html">Net::HTTPResponse</a>
|
362
|
+
instance.
|
363
|
+
</p>
|
364
|
+
<p>
|
365
|
+
Returns an array [<tt>metadata</tt>, +response.body+]; or nil if the object
|
366
|
+
doesn’t exist.
|
367
|
+
</p>
|
368
|
+
<p><a class="source-toggle" href="#"
|
369
|
+
onclick="toggleCode('M000094-source');return false;">[Source]</a></p>
|
370
|
+
<div class="method-source-code" id="M000094-source">
|
371
|
+
<pre>
|
372
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 112</span>
|
373
|
+
112: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse_response</span>(<span class="ruby-identifier">resp</span>)
|
374
|
+
113: <span class="ruby-identifier">resp_headers</span> = <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">to_hash</span>
|
375
|
+
114:
|
376
|
+
115: <span class="ruby-comment cmt"># If there's no etag, there's no content in the resource.</span>
|
377
|
+
116: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp_headers</span>[<span class="ruby-value str">'etag'</span>]
|
378
|
+
117: <span class="ruby-identifier">metadata</span> = {}
|
379
|
+
118: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:last_modified</span>] = <span class="ruby-identifier">resp_headers</span>[<span class="ruby-value str">'last-modified'</span>][<span class="ruby-value">0</span>]
|
380
|
+
119: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:etag</span>] = <span class="ruby-identifier">resp_headers</span>[<span class="ruby-value str">'etag'</span>][<span class="ruby-value">0</span>]
|
381
|
+
120: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:size</span>] = <span class="ruby-identifier">resp_headers</span>[<span class="ruby-value str">'content-length'</span>][<span class="ruby-value">0</span>]
|
382
|
+
121: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:content_type</span>] = <span class="ruby-identifier">resp_headers</span>[<span class="ruby-value str">'content-type'</span>][<span class="ruby-value">0</span>]
|
383
|
+
122:
|
384
|
+
123: <span class="ruby-comment cmt"># x-amz-meta- response headers.</span>
|
385
|
+
124: <span class="ruby-identifier">interesting_header</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">METADATA_PREFIX</span>)
|
386
|
+
125: <span class="ruby-identifier">amz_meta</span> = {}
|
387
|
+
126: <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">each_header</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
|
388
|
+
127: <span class="ruby-identifier">amz_meta</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-identifier">interesting_header</span>, <span class="ruby-value str">''</span>)] = <span class="ruby-identifier">value</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">interesting_header</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">key</span>
|
389
|
+
128: <span class="ruby-keyword kw">end</span>
|
390
|
+
129:
|
391
|
+
130: <span class="ruby-comment cmt"># The actual content of the S3 object.</span>
|
392
|
+
131: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">body</span>
|
393
|
+
132:
|
394
|
+
133: [<span class="ruby-identifier">metadata</span>, <span class="ruby-identifier">amz_meta</span>, <span class="ruby-identifier">value</span>]
|
395
|
+
134: <span class="ruby-keyword kw">else</span>
|
396
|
+
135: <span class="ruby-keyword kw">nil</span>
|
397
|
+
136: <span class="ruby-keyword kw">end</span>
|
398
|
+
137: <span class="ruby-keyword kw">end</span>
|
399
|
+
</pre>
|
400
|
+
</div>
|
401
|
+
</div>
|
402
|
+
</div>
|
403
|
+
|
404
|
+
<div id="method-M000092" class="method-detail">
|
405
|
+
<a name="M000092"></a>
|
406
|
+
|
407
|
+
<div class="method-heading">
|
408
|
+
<a href="#M000092" class="method-signature">
|
409
|
+
<span class="method-name">parse_xml_node</span><span class="method-args">(doc)</span>
|
410
|
+
</a>
|
411
|
+
</div>
|
412
|
+
|
413
|
+
<div class="method-description">
|
414
|
+
<p>
|
415
|
+
Get properties of the object from an <a href="../XML.html">XML</a>
|
416
|
+
document, e.g. as returned in a bucket listing.
|
417
|
+
</p>
|
418
|
+
<p>
|
419
|
+
<tt>doc</tt>: <a href="../XML/Document.html">XML::Document</a> instance to
|
420
|
+
parse to get properties for this object.
|
421
|
+
</p>
|
422
|
+
<p>
|
423
|
+
Returns the metadata relating to the object, as stored on S3.
|
424
|
+
</p>
|
425
|
+
<p><a class="source-toggle" href="#"
|
426
|
+
onclick="toggleCode('M000092-source');return false;">[Source]</a></p>
|
427
|
+
<div class="method-source-code" id="M000092-source">
|
428
|
+
<pre>
|
429
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 70</span>
|
430
|
+
70: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse_xml_node</span>(<span class="ruby-identifier">doc</span>)
|
431
|
+
71: <span class="ruby-identifier">metadata</span> = {}
|
432
|
+
72: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:key</span>] = <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">xget</span>(<span class="ruby-value str">'Key'</span>)
|
433
|
+
73: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:last_modified</span>] = <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">xget</span>(<span class="ruby-value str">'LastModified'</span>)
|
434
|
+
74: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:etag</span>] = <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">xget</span>(<span class="ruby-value str">'ETag'</span>)
|
435
|
+
75: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:size</span>] = <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">xget</span>(<span class="ruby-value str">'Size'</span>)
|
436
|
+
76:
|
437
|
+
77: <span class="ruby-comment cmt"># Build representation of the owner.</span>
|
438
|
+
78: <span class="ruby-identifier">user_xml_doc</span> = <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value str">'Owner'</span>).<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">first</span>
|
439
|
+
79: <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:owner</span>] = <span class="ruby-constant">S3ACL</span><span class="ruby-operator">::</span><span class="ruby-constant">CanonicalUser</span>.<span class="ruby-identifier">from_xml</span>(<span class="ruby-identifier">user_xml_doc</span>)
|
440
|
+
80:
|
441
|
+
81: <span class="ruby-identifier">metadata</span>
|
442
|
+
82: <span class="ruby-keyword kw">end</span>
|
190
443
|
</pre>
|
191
444
|
</div>
|
192
445
|
</div>
|
@@ -194,102 +447,157 @@ Create from a node.
|
|
194
447
|
|
195
448
|
<h3 class="section-bar">Public Instance methods</h3>
|
196
449
|
|
197
|
-
<div id="method-
|
198
|
-
<a name="
|
450
|
+
<div id="method-M000096" class="method-detail">
|
451
|
+
<a name="M000096"></a>
|
199
452
|
|
200
453
|
<div class="method-heading">
|
201
|
-
<a href="#
|
454
|
+
<a href="#M000096" class="method-signature">
|
202
455
|
<span class="method-name">delete</span><span class="method-args">()</span>
|
203
456
|
</a>
|
204
457
|
</div>
|
205
458
|
|
206
459
|
<div class="method-description">
|
207
460
|
<p>
|
208
|
-
Remove this object from associated <a
|
461
|
+
Remove this object from its associated <a
|
209
462
|
href="NamedBucket.html">NamedBucket</a>.
|
463
|
+
</p>
|
464
|
+
<p>
|
465
|
+
Returns false if this object is not associated with a bucket; otherwise
|
466
|
+
returns the response from S3.
|
210
467
|
</p>
|
211
468
|
<p><a class="source-toggle" href="#"
|
212
|
-
onclick="toggleCode('
|
213
|
-
<div class="method-source-code" id="
|
469
|
+
onclick="toggleCode('M000096-source');return false;">[Source]</a></p>
|
470
|
+
<div class="method-source-code" id="M000096-source">
|
214
471
|
<pre>
|
215
|
-
<span class="ruby-comment cmt"># File lib/s33r/
|
216
|
-
|
217
|
-
|
218
|
-
|
472
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 163</span>
|
473
|
+
163: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>
|
474
|
+
164: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@named_bucket</span>.<span class="ruby-identifier">nil?</span>
|
475
|
+
165: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
476
|
+
166: <span class="ruby-keyword kw">else</span>
|
477
|
+
167: <span class="ruby-ivar">@named_bucket</span>.<span class="ruby-identifier">delete_resource</span>(<span class="ruby-ivar">@key</span>)
|
478
|
+
168: <span class="ruby-keyword kw">end</span>
|
479
|
+
169: <span class="ruby-keyword kw">end</span>
|
219
480
|
</pre>
|
220
481
|
</div>
|
221
482
|
</div>
|
222
483
|
</div>
|
223
484
|
|
224
|
-
<div id="method-
|
225
|
-
<a name="
|
485
|
+
<div id="method-M000095" class="method-detail">
|
486
|
+
<a name="M000095"></a>
|
226
487
|
|
227
488
|
<div class="method-heading">
|
228
|
-
<a href="#
|
229
|
-
<span class="method-name">
|
489
|
+
<a href="#M000095" class="method-signature">
|
490
|
+
<span class="method-name">load</span><span class="method-args">()</span>
|
230
491
|
</a>
|
231
492
|
</div>
|
232
493
|
|
233
494
|
<div class="method-description">
|
234
495
|
<p>
|
235
|
-
|
236
|
-
|
496
|
+
Load content into this object from S3; will perform an HTTP request to
|
497
|
+
"refresh" the object (providing the object has an association
|
498
|
+
with a bucket it can use for piggybacking).
|
237
499
|
</p>
|
238
500
|
<p>
|
239
|
-
|
240
|
-
parse to get properties for this object.
|
501
|
+
Returns false if value cannot be retrieved.
|
241
502
|
</p>
|
242
503
|
<p><a class="source-toggle" href="#"
|
243
|
-
onclick="toggleCode('
|
244
|
-
<div class="method-source-code" id="
|
504
|
+
onclick="toggleCode('M000095-source');return false;">[Source]</a></p>
|
505
|
+
<div class="method-source-code" id="M000095-source">
|
245
506
|
<pre>
|
246
|
-
<span class="ruby-comment cmt"># File lib/s33r/
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
147: <span class="ruby-keyword kw">end</span>
|
507
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 144</span>
|
508
|
+
144: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load</span>
|
509
|
+
145: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@named_bucket</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@named_bucket</span>.<span class="ruby-identifier">key_exists?</span>(<span class="ruby-ivar">@key</span>)
|
510
|
+
146: <span class="ruby-identifier">resp</span> = <span class="ruby-ivar">@named_bucket</span>.<span class="ruby-identifier">get_raw</span>(<span class="ruby-ivar">@key</span>)
|
511
|
+
147: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">ok?</span>
|
512
|
+
148: <span class="ruby-ivar">@value</span> = <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">body</span>
|
513
|
+
149: <span class="ruby-ivar">@content_type</span> = <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">to_hash</span>[<span class="ruby-value str">'content-type'</span>]
|
514
|
+
150: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
|
515
|
+
151: <span class="ruby-keyword kw">else</span>
|
516
|
+
152: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
517
|
+
153: <span class="ruby-keyword kw">end</span>
|
518
|
+
154: <span class="ruby-keyword kw">else</span>
|
519
|
+
155: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
520
|
+
156: <span class="ruby-keyword kw">end</span>
|
521
|
+
157: <span class="ruby-keyword kw">end</span>
|
262
522
|
</pre>
|
263
523
|
</div>
|
264
524
|
</div>
|
265
525
|
</div>
|
266
526
|
|
267
|
-
<div id="method-
|
268
|
-
<a name="
|
527
|
+
<div id="method-M000097" class="method-detail">
|
528
|
+
<a name="M000097"></a>
|
269
529
|
|
270
530
|
<div class="method-heading">
|
271
|
-
<a href="#
|
272
|
-
<span class="method-name">
|
531
|
+
<a href="#M000097" class="method-signature">
|
532
|
+
<span class="method-name">save</span><span class="method-args">()</span>
|
273
533
|
</a>
|
274
534
|
</div>
|
275
535
|
|
276
536
|
<div class="method-description">
|
277
537
|
<p>
|
278
|
-
|
538
|
+
Save this object back into its bucket.
|
279
539
|
</p>
|
280
540
|
<p>
|
281
|
-
|
282
|
-
href="
|
283
|
-
as its root element.
|
541
|
+
Only works if the object has an associated <a
|
542
|
+
href="NamedBucket.html">NamedBucket</a>; returns false if it doesn’t.
|
284
543
|
</p>
|
285
544
|
<p><a class="source-toggle" href="#"
|
286
|
-
onclick="toggleCode('
|
287
|
-
<div class="method-source-code" id="
|
545
|
+
onclick="toggleCode('M000097-source');return false;">[Source]</a></p>
|
546
|
+
<div class="method-source-code" id="M000097-source">
|
547
|
+
<pre>
|
548
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 175</span>
|
549
|
+
175: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save</span>
|
550
|
+
176: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@named_bucket</span>.<span class="ruby-identifier">nil?</span>
|
551
|
+
177: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
552
|
+
178: <span class="ruby-keyword kw">else</span>
|
553
|
+
179: <span class="ruby-identifier">headers</span> = {}
|
554
|
+
180: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">"Content-Type"</span>] = <span class="ruby-ivar">@content_type</span> <span class="ruby-operator">||</span> <span class="ruby-value str">''</span>
|
555
|
+
181: <span class="ruby-identifier">headers</span> = <span class="ruby-identifier">metadata_headers</span>(<span class="ruby-identifier">headers</span>, <span class="ruby-identifier">meta</span>)
|
556
|
+
182: <span class="ruby-ivar">@named_bucket</span>.<span class="ruby-identifier">put_stream</span>(<span class="ruby-ivar">@value</span>, <span class="ruby-ivar">@key</span>, <span class="ruby-identifier">headers</span>)
|
557
|
+
183: <span class="ruby-keyword kw">end</span>
|
558
|
+
184: <span class="ruby-keyword kw">end</span>
|
559
|
+
</pre>
|
560
|
+
</div>
|
561
|
+
</div>
|
562
|
+
</div>
|
563
|
+
|
564
|
+
<div id="method-M000088" class="method-detail">
|
565
|
+
<a name="M000088"></a>
|
566
|
+
|
567
|
+
<div class="method-heading">
|
568
|
+
<a href="#M000088" class="method-signature">
|
569
|
+
<span class="method-name">set_properties</span><span class="method-args">(metadata)</span>
|
570
|
+
</a>
|
571
|
+
</div>
|
572
|
+
|
573
|
+
<div class="method-description">
|
574
|
+
<p>
|
575
|
+
Set the properties of the object from some metadata name-value pairs.
|
576
|
+
</p>
|
577
|
+
<p>
|
578
|
+
<tt>metadata</tt> is a hash of properties and their values, used to set the
|
579
|
+
corresponding properties on the object.
|
580
|
+
</p>
|
581
|
+
<p>
|
582
|
+
<tt>value</tt> is the data associated with the object on S3.
|
583
|
+
</p>
|
584
|
+
<p><a class="source-toggle" href="#"
|
585
|
+
onclick="toggleCode('M000088-source');return false;">[Source]</a></p>
|
586
|
+
<div class="method-source-code" id="M000088-source">
|
288
587
|
<pre>
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
588
|
+
<span class="ruby-comment cmt"># File lib/s33r/s3_obj.rb, line 26</span>
|
589
|
+
26: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_properties</span>(<span class="ruby-identifier">metadata</span>)
|
590
|
+
27: <span class="ruby-comment cmt"># required properties</span>
|
591
|
+
28: <span class="ruby-ivar">@etag</span> = <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:etag</span>].<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">"\""</span>, <span class="ruby-value str">""</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:etag</span>]
|
592
|
+
29: <span class="ruby-ivar">@last_modified</span> = <span class="ruby-constant">DateTime</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:last_modified</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:last_modified</span>]
|
593
|
+
30: <span class="ruby-ivar">@size</span> = <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:size</span>].<span class="ruby-identifier">to_i</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:size</span>]
|
594
|
+
31:
|
595
|
+
32: <span class="ruby-comment cmt"># only set if creating object from XML (not available otherwise)</span>
|
596
|
+
33: <span class="ruby-ivar">@owner</span> = <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:owner</span>]
|
597
|
+
34:
|
598
|
+
35: <span class="ruby-comment cmt"># only set if creating object from HTTP response</span>
|
599
|
+
36: <span class="ruby-ivar">@content_type</span> = <span class="ruby-identifier">metadata</span>[<span class="ruby-identifier">:content_type</span>]
|
600
|
+
37: <span class="ruby-keyword kw">end</span>
|
293
601
|
</pre>
|
294
602
|
</div>
|
295
603
|
</div>
|