s33r 0.2 → 0.3
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/bin/s3cli.rb +25 -16
- data/html/classes/MIME.html +120 -0
- data/html/classes/MIME/InvalidContentType.html +119 -0
- data/html/classes/MIME/Type.html +1173 -0
- data/html/classes/MIME/Types.html +566 -0
- data/html/classes/Net.html +108 -0
- data/html/classes/Net/HTTPGenericRequest.html +233 -0
- data/html/classes/Net/HTTPResponse.html +242 -0
- data/html/classes/S33r.html +743 -0
- data/html/classes/S33r/BucketListing.html +372 -0
- data/html/classes/S33r/Client.html +981 -0
- data/html/classes/S33r/NamedBucket.html +620 -0
- data/html/classes/S33r/S33rException.html +118 -0
- data/html/classes/S33r/S33rException/BucketListingMaxKeysError.html +111 -0
- data/html/classes/S33r/S33rException/InvalidBucketListing.html +111 -0
- data/html/classes/S33r/S33rException/MalformedBucketName.html +111 -0
- data/html/classes/S33r/S33rException/MethodNotAvailable.html +111 -0
- data/html/classes/S33r/S33rException/MissingRequiredHeaders.html +111 -0
- data/html/classes/S33r/S33rException/MissingResource.html +111 -0
- data/html/classes/S33r/S33rException/UnsupportedCannedACL.html +111 -0
- data/html/classes/S33r/S33rException/UnsupportedHTTPMethod.html +111 -0
- data/html/classes/S33r/S3Object.html +307 -0
- data/html/classes/S33r/S3User.html +171 -0
- data/html/classes/S33r/Sync.html +151 -0
- data/html/classes/XML.html +200 -0
- data/html/classes/XML/Document.html +125 -0
- data/html/classes/XML/Node.html +124 -0
- data/html/created.rid +1 -0
- data/html/files/CHANGELOG.html +101 -0
- data/html/files/MIT-LICENSE.html +129 -0
- data/html/files/README_txt.html +209 -0
- data/html/files/lib/s33r/bucket_listing_rb.html +116 -0
- data/html/files/lib/s33r/client_rb.html +110 -0
- data/html/files/lib/s33r/core_rb.html +113 -0
- data/html/files/lib/s33r/libxml_extensions_rb.html +107 -0
- data/html/files/lib/s33r/mimetypes_rb.html +120 -0
- data/html/files/lib/s33r/named_bucket_rb.html +101 -0
- data/html/files/lib/s33r/s33r_exception_rb.html +101 -0
- data/html/files/lib/s33r/s33r_http_rb.html +108 -0
- data/html/files/lib/s33r/sync_rb.html +101 -0
- data/html/files/lib/s33r_rb.html +101 -0
- data/html/fr_class_index.html +52 -0
- data/html/fr_file_index.html +39 -0
- data/html/fr_method_index.html +126 -0
- data/html/index.html +24 -0
- data/html/rdoc-style.css +208 -0
- data/lib/s33r/bucket_listing.rb +69 -60
- data/lib/s33r/client.rb +150 -73
- data/lib/s33r/core.rb +56 -44
- data/lib/s33r/libxml_extensions.rb +10 -5
- data/lib/s33r/mimetypes.rb +3 -2
- data/lib/s33r/named_bucket.rb +89 -24
- data/lib/s33r/{s3_exception.rb → s33r_exception.rb} +2 -2
- data/lib/s33r/{net_http_overrides.rb → s33r_http.rb} +29 -21
- data/lib/s33r/sync.rb +4 -2
- data/test/cases/spec_bucket_listing.rb +10 -13
- data/test/cases/spec_client.rb +65 -0
- data/test/cases/spec_core.rb +16 -11
- data/test/cases/spec_namedbucket.rb +32 -0
- data/test/cases/spec_sync.rb +6 -5
- data/test/cases/spec_xml.rb +1 -1
- data/test/files/client_config.yml +6 -0
- data/test/files/namedbucket_config.yml +12 -0
- data/test/{s3_test_constants.rb → test_setup.rb} +7 -6
- metadata +63 -11
- data/LICENSE.txt +0 -22
- data/MIT-LICENSE +0 -21
- data/README.txt +0 -19
- data/bin/config.yml +0 -5
- data/test/cases/unit_client.rb +0 -40
- data/test/cases/unit_named_bucket.rb +0 -12
@@ -0,0 +1,372 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: S33r::BucketListing</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">S33r::BucketListing</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/s33r/bucket_listing_rb.html">
|
59
|
+
lib/s33r/bucket_listing.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
<div id="description">
|
82
|
+
<p>
|
83
|
+
Object representation of the content of a bucket.
|
84
|
+
</p>
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
|
89
|
+
</div>
|
90
|
+
|
91
|
+
<div id="method-list">
|
92
|
+
<h3 class="section-bar">Methods</h3>
|
93
|
+
|
94
|
+
<div class="name-list">
|
95
|
+
<a href="#M000077">[]</a>
|
96
|
+
<a href="#M000074">new</a>
|
97
|
+
<a href="#M000076">parse_listing</a>
|
98
|
+
<a href="#M000078">pretty</a>
|
99
|
+
<a href="#M000075">set_listing_xml</a>
|
100
|
+
</div>
|
101
|
+
</div>
|
102
|
+
|
103
|
+
</div>
|
104
|
+
|
105
|
+
|
106
|
+
<!-- if includes -->
|
107
|
+
|
108
|
+
<div id="section">
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
<div id="attribute-list">
|
115
|
+
<h3 class="section-bar">Attributes</h3>
|
116
|
+
|
117
|
+
<div class="name-list">
|
118
|
+
<table>
|
119
|
+
<tr class="top-aligned-row context-row">
|
120
|
+
<td class="context-item-name">common_prefixes</td>
|
121
|
+
<td class="context-item-value"> [R] </td>
|
122
|
+
<td class="context-item-desc"></td>
|
123
|
+
</tr>
|
124
|
+
<tr class="top-aligned-row context-row">
|
125
|
+
<td class="context-item-name">contents</td>
|
126
|
+
<td class="context-item-value"> [R] </td>
|
127
|
+
<td class="context-item-desc">
|
128
|
+
Hash of objects in this bucket, keyed by their S3 keys.
|
129
|
+
|
130
|
+
</td>
|
131
|
+
</tr>
|
132
|
+
<tr class="top-aligned-row context-row">
|
133
|
+
<td class="context-item-name">delimiter</td>
|
134
|
+
<td class="context-item-value"> [R] </td>
|
135
|
+
<td class="context-item-desc"></td>
|
136
|
+
</tr>
|
137
|
+
<tr class="top-aligned-row context-row">
|
138
|
+
<td class="context-item-name">is_truncated</td>
|
139
|
+
<td class="context-item-value"> [R] </td>
|
140
|
+
<td class="context-item-desc"></td>
|
141
|
+
</tr>
|
142
|
+
<tr class="top-aligned-row context-row">
|
143
|
+
<td class="context-item-name">marker</td>
|
144
|
+
<td class="context-item-value"> [R] </td>
|
145
|
+
<td class="context-item-desc"></td>
|
146
|
+
</tr>
|
147
|
+
<tr class="top-aligned-row context-row">
|
148
|
+
<td class="context-item-name">max_keys</td>
|
149
|
+
<td class="context-item-value"> [R] </td>
|
150
|
+
<td class="context-item-desc"></td>
|
151
|
+
</tr>
|
152
|
+
<tr class="top-aligned-row context-row">
|
153
|
+
<td class="context-item-name">name</td>
|
154
|
+
<td class="context-item-value"> [R] </td>
|
155
|
+
<td class="context-item-desc">
|
156
|
+
Name of the bucket this listing is for.
|
157
|
+
|
158
|
+
</td>
|
159
|
+
</tr>
|
160
|
+
<tr class="top-aligned-row context-row">
|
161
|
+
<td class="context-item-name">named_bucket</td>
|
162
|
+
<td class="context-item-value"> [RW] </td>
|
163
|
+
<td class="context-item-desc">
|
164
|
+
A <a href="NamedBucket.html">NamedBucket</a> instance associated with this
|
165
|
+
listing.
|
166
|
+
|
167
|
+
</td>
|
168
|
+
</tr>
|
169
|
+
<tr class="top-aligned-row context-row">
|
170
|
+
<td class="context-item-name">prefix</td>
|
171
|
+
<td class="context-item-value"> [R] </td>
|
172
|
+
<td class="context-item-desc"></td>
|
173
|
+
</tr>
|
174
|
+
</table>
|
175
|
+
</div>
|
176
|
+
</div>
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
<!-- if method_list -->
|
181
|
+
<div id="methods">
|
182
|
+
<h3 class="section-bar">Public Class methods</h3>
|
183
|
+
|
184
|
+
<div id="method-M000074" class="method-detail">
|
185
|
+
<a name="M000074"></a>
|
186
|
+
|
187
|
+
<div class="method-heading">
|
188
|
+
<a href="#M000074" class="method-signature">
|
189
|
+
<span class="method-name">new</span><span class="method-args">(bucket_listing_xml, named_bucket=nil)</span>
|
190
|
+
</a>
|
191
|
+
</div>
|
192
|
+
|
193
|
+
<div class="method-description">
|
194
|
+
<p>
|
195
|
+
Create a new object representing a ListBucketResult.
|
196
|
+
</p>
|
197
|
+
<p>
|
198
|
+
<tt>bucket_listing_xml</tt> is a ListBucketResult document, as returned
|
199
|
+
from a GET on a bucket (see <a
|
200
|
+
href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01">docs.amazonwebservices.com/AmazonS3/2006-03-01</a>/).
|
201
|
+
</p>
|
202
|
+
<p>
|
203
|
+
<tt>named_bucket</tt> can be set to an existing <a
|
204
|
+
href="NamedBucket.html">NamedBucket</a> instance, so that any objects
|
205
|
+
inside this listing can be associated with that instance. This enables
|
206
|
+
objects to be easily deleted without having to create a new <a
|
207
|
+
href="Client.html">Client</a> instance.
|
208
|
+
</p>
|
209
|
+
<p><a class="source-toggle" href="#"
|
210
|
+
onclick="toggleCode('M000074-source');return false;">[Source]</a></p>
|
211
|
+
<div class="method-source-code" id="M000074-source">
|
212
|
+
<pre>
|
213
|
+
<span class="ruby-comment cmt"># File lib/s33r/bucket_listing.rb, line 27</span>
|
214
|
+
27: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">bucket_listing_xml</span>, <span class="ruby-identifier">named_bucket</span>=<span class="ruby-keyword kw">nil</span>)
|
215
|
+
28: <span class="ruby-ivar">@contents</span> = {}
|
216
|
+
29: <span class="ruby-ivar">@common_prefixes</span> = {}
|
217
|
+
30: <span class="ruby-comment cmt"># the NamedBucket instance associated with this listing (if any)</span>
|
218
|
+
31: <span class="ruby-ivar">@named_bucket</span> = <span class="ruby-identifier">named_bucket</span>
|
219
|
+
32: <span class="ruby-identifier">set_listing_xml</span>(<span class="ruby-identifier">bucket_listing_xml</span>)
|
220
|
+
33: <span class="ruby-keyword kw">end</span>
|
221
|
+
</pre>
|
222
|
+
</div>
|
223
|
+
</div>
|
224
|
+
</div>
|
225
|
+
|
226
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
227
|
+
|
228
|
+
<div id="method-M000077" class="method-detail">
|
229
|
+
<a name="M000077"></a>
|
230
|
+
|
231
|
+
<div class="method-heading">
|
232
|
+
<a href="#M000077" class="method-signature">
|
233
|
+
<span class="method-name">[]</span><span class="method-args">(key)</span>
|
234
|
+
</a>
|
235
|
+
</div>
|
236
|
+
|
237
|
+
<div class="method-description">
|
238
|
+
<p>
|
239
|
+
Return an object in this bucket by key.
|
240
|
+
</p>
|
241
|
+
<p><a class="source-toggle" href="#"
|
242
|
+
onclick="toggleCode('M000077-source');return false;">[Source]</a></p>
|
243
|
+
<div class="method-source-code" id="M000077-source">
|
244
|
+
<pre>
|
245
|
+
<span class="ruby-comment cmt"># File lib/s33r/bucket_listing.rb, line 72</span>
|
246
|
+
72: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-identifier">key</span>)
|
247
|
+
73: <span class="ruby-ivar">@contents</span>[<span class="ruby-identifier">key</span>]
|
248
|
+
74: <span class="ruby-keyword kw">end</span>
|
249
|
+
</pre>
|
250
|
+
</div>
|
251
|
+
</div>
|
252
|
+
</div>
|
253
|
+
|
254
|
+
<div id="method-M000076" class="method-detail">
|
255
|
+
<a name="M000076"></a>
|
256
|
+
|
257
|
+
<div class="method-heading">
|
258
|
+
<a href="#M000076" class="method-signature">
|
259
|
+
<span class="method-name">parse_listing</span><span class="method-args">(bucket_listing_xml)</span>
|
260
|
+
</a>
|
261
|
+
</div>
|
262
|
+
|
263
|
+
<div class="method-description">
|
264
|
+
<p>
|
265
|
+
Parse raw <a href="../XML.html">XML</a> ListBucketResponse from S3 into
|
266
|
+
object instances.
|
267
|
+
</p>
|
268
|
+
<p><a class="source-toggle" href="#"
|
269
|
+
onclick="toggleCode('M000076-source');return false;">[Source]</a></p>
|
270
|
+
<div class="method-source-code" id="M000076-source">
|
271
|
+
<pre>
|
272
|
+
<span class="ruby-comment cmt"># File lib/s33r/bucket_listing.rb, line 47</span>
|
273
|
+
47: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_listing</span>(<span class="ruby-identifier">bucket_listing_xml</span>)
|
274
|
+
48: <span class="ruby-identifier">doc</span> = <span class="ruby-constant">XML</span>.<span class="ruby-identifier">get_xml_doc</span>(<span class="ruby-identifier">bucket_listing_xml</span>)
|
275
|
+
49:
|
276
|
+
50: <span class="ruby-identifier">prop_setter</span> = <span class="ruby-identifier">lambda</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">prop</span>, <span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
|
277
|
+
51: <span class="ruby-identifier">node</span> = <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">find</span>(<span class="ruby-node">"//ListBucketResult/#{path}"</span>).<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">first</span>
|
278
|
+
52: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">"#{prop}="</span>, <span class="ruby-identifier">node</span>.<span class="ruby-identifier">content</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">node</span>
|
279
|
+
53: <span class="ruby-keyword kw">end</span>
|
280
|
+
54:
|
281
|
+
55: <span class="ruby-comment cmt"># metadata</span>
|
282
|
+
56: <span class="ruby-identifier">prop_setter</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">:name</span>, <span class="ruby-value str">'Name'</span>)
|
283
|
+
57: <span class="ruby-identifier">prop_setter</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">:delimiter</span>, <span class="ruby-value str">'Delimiter'</span>)
|
284
|
+
58: <span class="ruby-identifier">prop_setter</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">:prefix</span>, <span class="ruby-value str">'Prefix'</span>)
|
285
|
+
59: <span class="ruby-identifier">prop_setter</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">:marker</span>, <span class="ruby-value str">'Marker'</span>)
|
286
|
+
60: <span class="ruby-identifier">prop_setter</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">:max_keys</span>, <span class="ruby-value str">'MaxKeys'</span>)
|
287
|
+
61: <span class="ruby-identifier">prop_setter</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">:is_truncated</span>, <span class="ruby-value str">'IsTruncated'</span>)
|
288
|
+
62:
|
289
|
+
63: <span class="ruby-comment cmt"># contents</span>
|
290
|
+
64: <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value str">'//Contents'</span>).<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">node</span><span class="ruby-operator">|</span>
|
291
|
+
65: <span class="ruby-identifier">obj</span> = <span class="ruby-constant">S3Object</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">node</span>)
|
292
|
+
66: <span class="ruby-comment cmt"># Add to the content listing for the bucket</span>
|
293
|
+
67: <span class="ruby-ivar">@contents</span>[<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">obj</span>
|
294
|
+
68: <span class="ruby-keyword kw">end</span>
|
295
|
+
69: <span class="ruby-keyword kw">end</span>
|
296
|
+
</pre>
|
297
|
+
</div>
|
298
|
+
</div>
|
299
|
+
</div>
|
300
|
+
|
301
|
+
<div id="method-M000078" class="method-detail">
|
302
|
+
<a name="M000078"></a>
|
303
|
+
|
304
|
+
<div class="method-heading">
|
305
|
+
<a href="#M000078" class="method-signature">
|
306
|
+
<span class="method-name">pretty</span><span class="method-args">()</span>
|
307
|
+
</a>
|
308
|
+
</div>
|
309
|
+
|
310
|
+
<div class="method-description">
|
311
|
+
<p>
|
312
|
+
Pretty listing of keys in alphabetical order.
|
313
|
+
</p>
|
314
|
+
<p><a class="source-toggle" href="#"
|
315
|
+
onclick="toggleCode('M000078-source');return false;">[Source]</a></p>
|
316
|
+
<div class="method-source-code" id="M000078-source">
|
317
|
+
<pre>
|
318
|
+
<span class="ruby-comment cmt"># File lib/s33r/bucket_listing.rb, line 77</span>
|
319
|
+
77: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pretty</span>
|
320
|
+
78: <span class="ruby-ivar">@contents</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-identifier">k</span> }
|
321
|
+
79: <span class="ruby-keyword kw">end</span>
|
322
|
+
</pre>
|
323
|
+
</div>
|
324
|
+
</div>
|
325
|
+
</div>
|
326
|
+
|
327
|
+
<div id="method-M000075" class="method-detail">
|
328
|
+
<a name="M000075"></a>
|
329
|
+
|
330
|
+
<div class="method-heading">
|
331
|
+
<a href="#M000075" class="method-signature">
|
332
|
+
<span class="method-name">set_listing_xml</span><span class="method-args">(bucket_listing_xml)</span>
|
333
|
+
</a>
|
334
|
+
</div>
|
335
|
+
|
336
|
+
<div class="method-description">
|
337
|
+
<p>
|
338
|
+
Convert a ListBucketResult <a href="../XML.html">XML</a> document into an
|
339
|
+
object representation.
|
340
|
+
</p>
|
341
|
+
<p><a class="source-toggle" href="#"
|
342
|
+
onclick="toggleCode('M000075-source');return false;">[Source]</a></p>
|
343
|
+
<div class="method-source-code" id="M000075-source">
|
344
|
+
<pre>
|
345
|
+
<span class="ruby-comment cmt"># File lib/s33r/bucket_listing.rb, line 36</span>
|
346
|
+
36: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_listing_xml</span>(<span class="ruby-identifier">bucket_listing_xml</span>)
|
347
|
+
37: <span class="ruby-comment cmt"># remove the namespace declaration: libxml doesn't like it</span>
|
348
|
+
38: <span class="ruby-identifier">bucket_listing_xml</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/ xmlns="http:\/\/s3.amazonaws.com\/doc\/2006-03-01\/"/</span>, <span class="ruby-value str">''</span>)
|
349
|
+
39: <span class="ruby-identifier">parse_listing</span>(<span class="ruby-identifier">bucket_listing_xml</span>)
|
350
|
+
40: <span class="ruby-keyword kw">rescue</span>
|
351
|
+
41: <span class="ruby-identifier">message</span> = <span class="ruby-value str">"Cannot create bucket listing from supplied XML"</span>
|
352
|
+
42: <span class="ruby-identifier">message</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">" (was nil)"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">bucket_listing_xml</span>.<span class="ruby-identifier">nil?</span>
|
353
|
+
43: <span class="ruby-identifier">raise</span> <span class="ruby-constant">S33rException</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidBucketListing</span>, <span class="ruby-identifier">message</span>
|
354
|
+
44: <span class="ruby-keyword kw">end</span>
|
355
|
+
</pre>
|
356
|
+
</div>
|
357
|
+
</div>
|
358
|
+
</div>
|
359
|
+
|
360
|
+
|
361
|
+
</div>
|
362
|
+
|
363
|
+
|
364
|
+
</div>
|
365
|
+
|
366
|
+
|
367
|
+
<div id="validator-badges">
|
368
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
369
|
+
</div>
|
370
|
+
|
371
|
+
</body>
|
372
|
+
</html>
|
@@ -0,0 +1,981 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: S33r::Client</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">S33r::Client</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/s33r/client_rb.html">
|
59
|
+
lib/s33r/client.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
<div id="description">
|
82
|
+
<p>
|
83
|
+
The client performs operations over the network, using the core to build
|
84
|
+
request headers and content; only client-specific headers are managed here:
|
85
|
+
other headers can be handled by the core.
|
86
|
+
</p>
|
87
|
+
|
88
|
+
</div>
|
89
|
+
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
<div id="method-list">
|
94
|
+
<h3 class="section-bar">Methods</h3>
|
95
|
+
|
96
|
+
<div class="name-list">
|
97
|
+
<a href="#M000095">add_client_headers</a>
|
98
|
+
<a href="#M000089">bucket_exists?</a>
|
99
|
+
<a href="#M000087">create_bucket</a>
|
100
|
+
<a href="#M000088">delete_bucket</a>
|
101
|
+
<a href="#M000094">delete_resource</a>
|
102
|
+
<a href="#M000100">do_delete</a>
|
103
|
+
<a href="#M000096">do_get</a>
|
104
|
+
<a href="#M000097">do_head</a>
|
105
|
+
<a href="#M000098">do_post</a>
|
106
|
+
<a href="#M000099">do_put</a>
|
107
|
+
<a href="#M000083">do_request</a>
|
108
|
+
<a href="#M000084">get_requester</a>
|
109
|
+
<a href="#M000090">get_resource</a>
|
110
|
+
<a href="#M000080">init</a>
|
111
|
+
<a href="#M000086">list_bucket</a>
|
112
|
+
<a href="#M000085">list_buckets</a>
|
113
|
+
<a href="#M000081">load_config</a>
|
114
|
+
<a href="#M000079">new</a>
|
115
|
+
<a href="#M000093">put_file</a>
|
116
|
+
<a href="#M000091">put_resource</a>
|
117
|
+
<a href="#M000092">put_text</a>
|
118
|
+
<a href="#M000082">use_ssl?</a>
|
119
|
+
</div>
|
120
|
+
</div>
|
121
|
+
|
122
|
+
</div>
|
123
|
+
|
124
|
+
|
125
|
+
<!-- if includes -->
|
126
|
+
<div id="includes">
|
127
|
+
<h3 class="section-bar">Included Modules</h3>
|
128
|
+
|
129
|
+
<div id="includes-list">
|
130
|
+
<span class="include-name"><a href="../S33r.html">S33r</a></span>
|
131
|
+
</div>
|
132
|
+
</div>
|
133
|
+
|
134
|
+
<div id="section">
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
<div id="attribute-list">
|
141
|
+
<h3 class="section-bar">Attributes</h3>
|
142
|
+
|
143
|
+
<div class="name-list">
|
144
|
+
<table>
|
145
|
+
<tr class="top-aligned-row context-row">
|
146
|
+
<td class="context-item-name">aws_access_key</td>
|
147
|
+
<td class="context-item-value"> [RW] </td>
|
148
|
+
<td class="context-item-desc"></td>
|
149
|
+
</tr>
|
150
|
+
<tr class="top-aligned-row context-row">
|
151
|
+
<td class="context-item-name">aws_secret_access_key</td>
|
152
|
+
<td class="context-item-value"> [RW] </td>
|
153
|
+
<td class="context-item-desc"></td>
|
154
|
+
</tr>
|
155
|
+
<tr class="top-aligned-row context-row">
|
156
|
+
<td class="context-item-name">chunk_size</td>
|
157
|
+
<td class="context-item-value"> [RW] </td>
|
158
|
+
<td class="context-item-desc">
|
159
|
+
Size of data chunk to be sent per request when putting data.
|
160
|
+
|
161
|
+
</td>
|
162
|
+
</tr>
|
163
|
+
<tr class="top-aligned-row context-row">
|
164
|
+
<td class="context-item-name">client_headers</td>
|
165
|
+
<td class="context-item-value"> [RW] </td>
|
166
|
+
<td class="context-item-desc">
|
167
|
+
Headers which should be sent with every request by default (unless
|
168
|
+
overridden).
|
169
|
+
|
170
|
+
</td>
|
171
|
+
</tr>
|
172
|
+
</table>
|
173
|
+
</div>
|
174
|
+
</div>
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
<!-- if method_list -->
|
179
|
+
<div id="methods">
|
180
|
+
<h3 class="section-bar">Public Class methods</h3>
|
181
|
+
|
182
|
+
<div id="method-M000080" class="method-detail">
|
183
|
+
<a name="M000080"></a>
|
184
|
+
|
185
|
+
<div class="method-heading">
|
186
|
+
<a href="#M000080" class="method-signature">
|
187
|
+
<span class="method-name">init</span><span class="method-args">(config_file)</span>
|
188
|
+
</a>
|
189
|
+
</div>
|
190
|
+
|
191
|
+
<div class="method-description">
|
192
|
+
<p>
|
193
|
+
Initialise client from YAML configuration file (see <a
|
194
|
+
href="Client.html#M000081">load_config</a> method for details of acceptable
|
195
|
+
format).
|
196
|
+
</p>
|
197
|
+
<p><a class="source-toggle" href="#"
|
198
|
+
onclick="toggleCode('M000080-source');return false;">[Source]</a></p>
|
199
|
+
<div class="method-source-code" id="M000080-source">
|
200
|
+
<pre>
|
201
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 58</span>
|
202
|
+
58: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Client</span>.<span class="ruby-identifier">init</span>(<span class="ruby-identifier">config_file</span>)
|
203
|
+
59: <span class="ruby-identifier">aws_access_key</span>, <span class="ruby-identifier">aws_secret_access_key</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">_</span> = <span class="ruby-identifier">load_config</span>(<span class="ruby-identifier">config_file</span>)
|
204
|
+
60: <span class="ruby-constant">Client</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">aws_access_key</span>, <span class="ruby-identifier">aws_secret_access_key</span>, <span class="ruby-identifier">options</span>)
|
205
|
+
61: <span class="ruby-keyword kw">end</span>
|
206
|
+
</pre>
|
207
|
+
</div>
|
208
|
+
</div>
|
209
|
+
</div>
|
210
|
+
|
211
|
+
<div id="method-M000081" class="method-detail">
|
212
|
+
<a name="M000081"></a>
|
213
|
+
|
214
|
+
<div class="method-heading">
|
215
|
+
<a href="#M000081" class="method-signature">
|
216
|
+
<span class="method-name">load_config</span><span class="method-args">(config_file)</span>
|
217
|
+
</a>
|
218
|
+
</div>
|
219
|
+
|
220
|
+
<div class="method-description">
|
221
|
+
<p>
|
222
|
+
Load YAML config. file for a client. The config. file looks like this:
|
223
|
+
</p>
|
224
|
+
<pre>
|
225
|
+
aws_access_key: 'youraccesskey'
|
226
|
+
aws_secret_access_key: 'yoursecretkey'
|
227
|
+
# options for Client or NamedBucket instances
|
228
|
+
options:
|
229
|
+
strict: false
|
230
|
+
public_contents: true
|
231
|
+
use_ssl: false
|
232
|
+
default_bucket: 'nobucket'
|
233
|
+
# extensions used in your own program
|
234
|
+
custom:
|
235
|
+
to_email: 'me@example.com'
|
236
|
+
from_email: 'you@example.com'#
|
237
|
+
</pre>
|
238
|
+
<p>
|
239
|
+
The <tt>options</tt> section contains settings specific to <a
|
240
|
+
href="Client.html">Client</a> and NamedClient instances; <tt>custom</tt>
|
241
|
+
contains extra settings specific to your application. <tt>options</tt> and
|
242
|
+
<tt>custom</tt> sections can be omitted, but settings for AWS keys are
|
243
|
+
required.
|
244
|
+
</p>
|
245
|
+
<p>
|
246
|
+
Returns an array <tt>[aws_access_key, aws_secret_access_key, options,
|
247
|
+
custom]</tt>, where <tt>options</tt> and <tt>custom</tt> are hashes.
|
248
|
+
</p>
|
249
|
+
<p><a class="source-toggle" href="#"
|
250
|
+
onclick="toggleCode('M000081-source');return false;">[Source]</a></p>
|
251
|
+
<div class="method-source-code" id="M000081-source">
|
252
|
+
<pre>
|
253
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 73</span>
|
254
|
+
73: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Client</span>.<span class="ruby-identifier">load_config</span>(<span class="ruby-identifier">config_file</span>)
|
255
|
+
74: <span class="ruby-identifier">require</span> <span class="ruby-value str">'yaml'</span>
|
256
|
+
75: <span class="ruby-identifier">config</span> = <span class="ruby-constant">YAML</span><span class="ruby-operator">::</span><span class="ruby-identifier">load_file</span>(<span class="ruby-identifier">config_file</span>)
|
257
|
+
76: <span class="ruby-identifier">aws_access_key</span> = <span class="ruby-identifier">config</span>[<span class="ruby-value str">'aws_access_key'</span>]
|
258
|
+
77: <span class="ruby-identifier">aws_secret_access_key</span> = <span class="ruby-identifier">config</span>[<span class="ruby-value str">'aws_secret_access_key'</span>]
|
259
|
+
78:
|
260
|
+
79: <span class="ruby-identifier">options</span> = {}
|
261
|
+
80: <span class="ruby-identifier">options</span> = <span class="ruby-constant">S33r</span>.<span class="ruby-identifier">keys_to_symbols</span>(<span class="ruby-identifier">config</span>[<span class="ruby-value str">'options'</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">config</span>[<span class="ruby-value str">'options'</span>]
|
262
|
+
81:
|
263
|
+
82: <span class="ruby-identifier">custom</span> = {}
|
264
|
+
83: <span class="ruby-identifier">custom</span> = <span class="ruby-constant">S33r</span>.<span class="ruby-identifier">keys_to_symbols</span>(<span class="ruby-identifier">config</span>[<span class="ruby-value str">'custom'</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">config</span>[<span class="ruby-value str">'custom'</span>]
|
265
|
+
84:
|
266
|
+
85: [<span class="ruby-identifier">aws_access_key</span>, <span class="ruby-identifier">aws_secret_access_key</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">custom</span>]
|
267
|
+
86: <span class="ruby-keyword kw">end</span>
|
268
|
+
</pre>
|
269
|
+
</div>
|
270
|
+
</div>
|
271
|
+
</div>
|
272
|
+
|
273
|
+
<div id="method-M000079" class="method-detail">
|
274
|
+
<a name="M000079"></a>
|
275
|
+
|
276
|
+
<div class="method-heading">
|
277
|
+
<a href="#M000079" class="method-signature">
|
278
|
+
<span class="method-name">new</span><span class="method-args">(aws_access_key, aws_secret_access_key, options={})</span>
|
279
|
+
</a>
|
280
|
+
</div>
|
281
|
+
|
282
|
+
<div class="method-description">
|
283
|
+
<p>
|
284
|
+
Configure either an SSL-enabled or plain HTTP client. (If using SSL, no
|
285
|
+
verification of server certificate is performed.)
|
286
|
+
</p>
|
287
|
+
<p>
|
288
|
+
<tt>options</tt>: hash of optional client config.:
|
289
|
+
</p>
|
290
|
+
<ul>
|
291
|
+
<li><tt>:use_ssl => false</tt>: only use plain HTTP for connections
|
292
|
+
|
293
|
+
</li>
|
294
|
+
<li><tt>:dump_requests => true</tt>: dump each request’s initial line
|
295
|
+
and headers to STDOUT
|
296
|
+
|
297
|
+
</li>
|
298
|
+
</ul>
|
299
|
+
<p><a class="source-toggle" href="#"
|
300
|
+
onclick="toggleCode('M000079-source');return false;">[Source]</a></p>
|
301
|
+
<div class="method-source-code" id="M000079-source">
|
302
|
+
<pre>
|
303
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 32</span>
|
304
|
+
32: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">aws_access_key</span>, <span class="ruby-identifier">aws_secret_access_key</span>, <span class="ruby-identifier">options</span>={})
|
305
|
+
33: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">false</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:use_ssl</span>]
|
306
|
+
34: <span class="ruby-ivar">@client</span> = <span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">HOST</span>, <span class="ruby-constant">NON_SSL_PORT</span>)
|
307
|
+
35: <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">use_ssl</span> = <span class="ruby-keyword kw">false</span>
|
308
|
+
36: <span class="ruby-keyword kw">else</span>
|
309
|
+
37: <span class="ruby-ivar">@client</span> = <span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">HOST</span>, <span class="ruby-constant">PORT</span>)
|
310
|
+
38: <span class="ruby-comment cmt"># turn off SSL certificate verification</span>
|
311
|
+
39: <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">verify_mode</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">VERIFY_NONE</span>
|
312
|
+
40: <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">use_ssl</span> = <span class="ruby-keyword kw">true</span>
|
313
|
+
41: <span class="ruby-keyword kw">end</span>
|
314
|
+
42:
|
315
|
+
43: <span class="ruby-ivar">@dump_requests</span> = (<span class="ruby-keyword kw">true</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:dump_requests</span>])
|
316
|
+
44:
|
317
|
+
45: <span class="ruby-comment cmt"># set default chunk size for streaming request body</span>
|
318
|
+
46: <span class="ruby-ivar">@chunk_size</span> = <span class="ruby-constant">DEFAULT_CHUNK_SIZE</span>
|
319
|
+
47:
|
320
|
+
48: <span class="ruby-comment cmt"># Amazon S3 developer keys</span>
|
321
|
+
49: <span class="ruby-ivar">@aws_access_key</span> = <span class="ruby-identifier">aws_access_key</span>
|
322
|
+
50: <span class="ruby-ivar">@aws_secret_access_key</span> = <span class="ruby-identifier">aws_secret_access_key</span>
|
323
|
+
51:
|
324
|
+
52: <span class="ruby-comment cmt"># headers sent with every request made by this client</span>
|
325
|
+
53: <span class="ruby-ivar">@client_headers</span> = {}
|
326
|
+
54: <span class="ruby-keyword kw">end</span>
|
327
|
+
</pre>
|
328
|
+
</div>
|
329
|
+
</div>
|
330
|
+
</div>
|
331
|
+
|
332
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
333
|
+
|
334
|
+
<div id="method-M000095" class="method-detail">
|
335
|
+
<a name="M000095"></a>
|
336
|
+
|
337
|
+
<div class="method-heading">
|
338
|
+
<a href="#M000095" class="method-signature">
|
339
|
+
<span class="method-name">add_client_headers</span><span class="method-args">(headers)</span>
|
340
|
+
</a>
|
341
|
+
</div>
|
342
|
+
|
343
|
+
<div class="method-description">
|
344
|
+
<p>
|
345
|
+
Add any default headers which should be sent with every request from the
|
346
|
+
client.
|
347
|
+
</p>
|
348
|
+
<p>
|
349
|
+
<tt>headers</tt> is a hash of headers already set up. Any headers passed in
|
350
|
+
here override the defaults in <tt>client_headers</tt>.
|
351
|
+
</p>
|
352
|
+
<p>
|
353
|
+
Returns <tt>headers</tt> with the content of <tt>client_headers</tt> merged
|
354
|
+
in.
|
355
|
+
</p>
|
356
|
+
<p><a class="source-toggle" href="#"
|
357
|
+
onclick="toggleCode('M000095-source');return false;">[Source]</a></p>
|
358
|
+
<div class="method-source-code" id="M000095-source">
|
359
|
+
<pre>
|
360
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 270</span>
|
361
|
+
270: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_client_headers</span>(<span class="ruby-identifier">headers</span>)
|
362
|
+
271: <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">client_headers</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">arg</span>, <span class="ruby-identifier">default</span><span class="ruby-operator">|</span> <span class="ruby-identifier">arg</span> }
|
363
|
+
272: <span class="ruby-keyword kw">end</span>
|
364
|
+
</pre>
|
365
|
+
</div>
|
366
|
+
</div>
|
367
|
+
</div>
|
368
|
+
|
369
|
+
<div id="method-M000089" class="method-detail">
|
370
|
+
<a name="M000089"></a>
|
371
|
+
|
372
|
+
<div class="method-heading">
|
373
|
+
<a href="#M000089" class="method-signature">
|
374
|
+
<span class="method-name">bucket_exists?</span><span class="method-args">(bucket_name)</span>
|
375
|
+
</a>
|
376
|
+
</div>
|
377
|
+
|
378
|
+
<div class="method-description">
|
379
|
+
<p>
|
380
|
+
Returns true if bucket exists.
|
381
|
+
</p>
|
382
|
+
<p><a class="source-toggle" href="#"
|
383
|
+
onclick="toggleCode('M000089-source');return false;">[Source]</a></p>
|
384
|
+
<div class="method-source-code" id="M000089-source">
|
385
|
+
<pre>
|
386
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 196</span>
|
387
|
+
196: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">bucket_exists?</span>(<span class="ruby-identifier">bucket_name</span>)
|
388
|
+
197: <span class="ruby-identifier">do_head</span>(<span class="ruby-node">"/#{bucket_name}"</span>).<span class="ruby-identifier">ok?</span>
|
389
|
+
198: <span class="ruby-keyword kw">end</span>
|
390
|
+
</pre>
|
391
|
+
</div>
|
392
|
+
</div>
|
393
|
+
</div>
|
394
|
+
|
395
|
+
<div id="method-M000087" class="method-detail">
|
396
|
+
<a name="M000087"></a>
|
397
|
+
|
398
|
+
<div class="method-heading">
|
399
|
+
<a href="#M000087" class="method-signature">
|
400
|
+
<span class="method-name">create_bucket</span><span class="method-args">(bucket_name, headers={})</span>
|
401
|
+
</a>
|
402
|
+
</div>
|
403
|
+
|
404
|
+
<div class="method-description">
|
405
|
+
<p>
|
406
|
+
Create a bucket.
|
407
|
+
</p>
|
408
|
+
<p><a class="source-toggle" href="#"
|
409
|
+
onclick="toggleCode('M000087-source');return false;">[Source]</a></p>
|
410
|
+
<div class="method-source-code" id="M000087-source">
|
411
|
+
<pre>
|
412
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 175</span>
|
413
|
+
175: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_bucket</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">headers</span>={})
|
414
|
+
176: <span class="ruby-identifier">do_put</span>(<span class="ruby-node">"/#{bucket_name}"</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span>)
|
415
|
+
177: <span class="ruby-keyword kw">end</span>
|
416
|
+
</pre>
|
417
|
+
</div>
|
418
|
+
</div>
|
419
|
+
</div>
|
420
|
+
|
421
|
+
<div id="method-M000088" class="method-detail">
|
422
|
+
<a name="M000088"></a>
|
423
|
+
|
424
|
+
<div class="method-heading">
|
425
|
+
<a href="#M000088" class="method-signature">
|
426
|
+
<span class="method-name">delete_bucket</span><span class="method-args">(bucket_name, headers={}, options={})</span>
|
427
|
+
</a>
|
428
|
+
</div>
|
429
|
+
|
430
|
+
<div class="method-description">
|
431
|
+
<p>
|
432
|
+
Delete a bucket.
|
433
|
+
</p>
|
434
|
+
<p>
|
435
|
+
<tt>options</tt> hash can contain the following:
|
436
|
+
</p>
|
437
|
+
<ul>
|
438
|
+
<li><tt>:force => true</tt>: delete all keys within the bucket then delete
|
439
|
+
the bucket itself
|
440
|
+
|
441
|
+
</li>
|
442
|
+
</ul>
|
443
|
+
<p><a class="source-toggle" href="#"
|
444
|
+
onclick="toggleCode('M000088-source');return false;">[Source]</a></p>
|
445
|
+
<div class="method-source-code" id="M000088-source">
|
446
|
+
<pre>
|
447
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 184</span>
|
448
|
+
184: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_bucket</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">headers</span>={}, <span class="ruby-identifier">options</span>={})
|
449
|
+
185: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:force</span>]
|
450
|
+
186: <span class="ruby-identifier">_</span>, <span class="ruby-identifier">bucket_listing</span> = <span class="ruby-identifier">list_bucket</span>(<span class="ruby-identifier">bucket_name</span>)
|
451
|
+
187: <span class="ruby-identifier">bucket_listing</span>.<span class="ruby-identifier">contents</span>.<span class="ruby-identifier">each_value</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">obj</span><span class="ruby-operator">|</span>
|
452
|
+
188: <span class="ruby-identifier">delete_resource</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">key</span>)
|
453
|
+
189: <span class="ruby-keyword kw">end</span>
|
454
|
+
190: <span class="ruby-keyword kw">end</span>
|
455
|
+
191:
|
456
|
+
192: <span class="ruby-identifier">do_delete</span>(<span class="ruby-node">"/#{bucket_name}"</span>, <span class="ruby-identifier">headers</span>)
|
457
|
+
193: <span class="ruby-keyword kw">end</span>
|
458
|
+
</pre>
|
459
|
+
</div>
|
460
|
+
</div>
|
461
|
+
</div>
|
462
|
+
|
463
|
+
<div id="method-M000094" class="method-detail">
|
464
|
+
<a name="M000094"></a>
|
465
|
+
|
466
|
+
<div class="method-heading">
|
467
|
+
<a href="#M000094" class="method-signature">
|
468
|
+
<span class="method-name">delete_resource</span><span class="method-args">(bucket_name, resource_key, headers={})</span>
|
469
|
+
</a>
|
470
|
+
</div>
|
471
|
+
|
472
|
+
<div class="method-description">
|
473
|
+
<p>
|
474
|
+
Delete a resource from S3.
|
475
|
+
</p>
|
476
|
+
<p><a class="source-toggle" href="#"
|
477
|
+
onclick="toggleCode('M000094-source');return false;">[Source]</a></p>
|
478
|
+
<div class="method-source-code" id="M000094-source">
|
479
|
+
<pre>
|
480
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 260</span>
|
481
|
+
260: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_resource</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>, <span class="ruby-identifier">headers</span>={})
|
482
|
+
261: <span class="ruby-identifier">do_delete</span>(<span class="ruby-node">"/#{bucket_name}/#{resource_key}"</span>, <span class="ruby-identifier">headers</span>)
|
483
|
+
262: <span class="ruby-keyword kw">end</span>
|
484
|
+
</pre>
|
485
|
+
</div>
|
486
|
+
</div>
|
487
|
+
</div>
|
488
|
+
|
489
|
+
<div id="method-M000083" class="method-detail">
|
490
|
+
<a name="M000083"></a>
|
491
|
+
|
492
|
+
<div class="method-heading">
|
493
|
+
<a href="#M000083" class="method-signature">
|
494
|
+
<span class="method-name">do_request</span><span class="method-args">(method, path, data=nil, headers={})</span>
|
495
|
+
</a>
|
496
|
+
</div>
|
497
|
+
|
498
|
+
<div class="method-description">
|
499
|
+
<p>
|
500
|
+
Send a request over the wire.
|
501
|
+
</p>
|
502
|
+
<p>
|
503
|
+
This method streams <tt>data</tt> if it responds to the <tt>stat</tt>
|
504
|
+
method (as files do).
|
505
|
+
</p>
|
506
|
+
<p><a class="source-toggle" href="#"
|
507
|
+
onclick="toggleCode('M000083-source');return false;">[Source]</a></p>
|
508
|
+
<div class="method-source-code" id="M000083-source">
|
509
|
+
<pre>
|
510
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 99</span>
|
511
|
+
99: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">do_request</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">data</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span>={})
|
512
|
+
100: <span class="ruby-identifier">req</span> = <span class="ruby-identifier">get_requester</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">path</span>)
|
513
|
+
101: <span class="ruby-identifier">req</span>.<span class="ruby-identifier">chunk_size</span> = <span class="ruby-ivar">@chunk_size</span>
|
514
|
+
102:
|
515
|
+
103: <span class="ruby-comment cmt"># add the S3 headers which are always required</span>
|
516
|
+
104: <span class="ruby-identifier">headers</span> = <span class="ruby-identifier">add_default_headers</span>(<span class="ruby-identifier">headers</span>)
|
517
|
+
105:
|
518
|
+
106: <span class="ruby-comment cmt"># add any client-specific default headers</span>
|
519
|
+
107: <span class="ruby-identifier">headers</span> = <span class="ruby-identifier">add_client_headers</span>(<span class="ruby-identifier">headers</span>)
|
520
|
+
108:
|
521
|
+
109: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">'Authorization'</span>] = <span class="ruby-identifier">generate_auth_header_value</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">headers</span>,
|
522
|
+
110: <span class="ruby-ivar">@aws_access_key</span>, <span class="ruby-ivar">@aws_secret_access_key</span>)
|
523
|
+
111:
|
524
|
+
112: <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">each</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>
|
525
|
+
113: <span class="ruby-identifier">req</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
|
526
|
+
114: <span class="ruby-keyword kw">end</span>
|
527
|
+
115:
|
528
|
+
116: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">req</span>.<span class="ruby-identifier">request_body_permitted?</span>
|
529
|
+
117: <span class="ruby-comment cmt"># for streaming files; NB Content-Length will be set by Net::HTTP</span>
|
530
|
+
118: <span class="ruby-comment cmt"># for character-based body content</span>
|
531
|
+
119: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:stat</span>)
|
532
|
+
120: <span class="ruby-identifier">req</span>.<span class="ruby-identifier">body_stream</span> = <span class="ruby-identifier">data</span>
|
533
|
+
121: <span class="ruby-identifier">req</span>[<span class="ruby-value str">'Content-Length'</span>] = <span class="ruby-identifier">data</span>.<span class="ruby-identifier">stat</span>.<span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span>
|
534
|
+
122: <span class="ruby-identifier">data</span> = <span class="ruby-keyword kw">nil</span>
|
535
|
+
123: <span class="ruby-keyword kw">end</span>
|
536
|
+
124: <span class="ruby-keyword kw">else</span>
|
537
|
+
125: <span class="ruby-identifier">data</span> = <span class="ruby-keyword kw">nil</span>
|
538
|
+
126: <span class="ruby-keyword kw">end</span>
|
539
|
+
127:
|
540
|
+
128: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@dump_requests</span>
|
541
|
+
129: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">req</span>.<span class="ruby-identifier">to_s</span>
|
542
|
+
130: <span class="ruby-keyword kw">end</span>
|
543
|
+
131:
|
544
|
+
132: <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">start</span> <span class="ruby-keyword kw">do</span>
|
545
|
+
133: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">request</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">data</span>)
|
546
|
+
134: <span class="ruby-keyword kw">end</span>
|
547
|
+
135:
|
548
|
+
136: <span class="ruby-keyword kw">end</span>
|
549
|
+
</pre>
|
550
|
+
</div>
|
551
|
+
</div>
|
552
|
+
</div>
|
553
|
+
|
554
|
+
<div id="method-M000084" class="method-detail">
|
555
|
+
<a name="M000084"></a>
|
556
|
+
|
557
|
+
<div class="method-heading">
|
558
|
+
<a href="#M000084" class="method-signature">
|
559
|
+
<span class="method-name">get_requester</span><span class="method-args">(method, path)</span>
|
560
|
+
</a>
|
561
|
+
</div>
|
562
|
+
|
563
|
+
<div class="method-description">
|
564
|
+
<p>
|
565
|
+
Return an instance of an appropriate request class.
|
566
|
+
</p>
|
567
|
+
<p><a class="source-toggle" href="#"
|
568
|
+
onclick="toggleCode('M000084-source');return false;">[Source]</a></p>
|
569
|
+
<div class="method-source-code" id="M000084-source">
|
570
|
+
<pre>
|
571
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 139</span>
|
572
|
+
139: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_requester</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">path</span>)
|
573
|
+
140: <span class="ruby-identifier">raise</span> <span class="ruby-constant">S33rException</span><span class="ruby-operator">::</span><span class="ruby-constant">UnsupportedHTTPMethod</span>, <span class="ruby-node">"The #{method} HTTP method is not supported"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span>(<span class="ruby-constant">METHOD_VERBS</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">method</span>))
|
574
|
+
141: <span class="ruby-identifier">eval</span>(<span class="ruby-value str">"HTTP::"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">method</span>[<span class="ruby-value">0</span>,<span class="ruby-value">1</span>].<span class="ruby-identifier">upcase</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">method</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>].<span class="ruby-identifier">downcase</span> <span class="ruby-operator">+</span> <span class="ruby-node">".new('#{path}')"</span>)
|
575
|
+
142: <span class="ruby-keyword kw">end</span>
|
576
|
+
</pre>
|
577
|
+
</div>
|
578
|
+
</div>
|
579
|
+
</div>
|
580
|
+
|
581
|
+
<div id="method-M000090" class="method-detail">
|
582
|
+
<a name="M000090"></a>
|
583
|
+
|
584
|
+
<div class="method-heading">
|
585
|
+
<a href="#M000090" class="method-signature">
|
586
|
+
<span class="method-name">get_resource</span><span class="method-args">(bucket_name, resource_key, headers={})</span>
|
587
|
+
</a>
|
588
|
+
</div>
|
589
|
+
|
590
|
+
<div class="method-description">
|
591
|
+
<p>
|
592
|
+
Fetch a resource and return a fleshed-out <a
|
593
|
+
href="S3Object.html">S3Object</a> instance.
|
594
|
+
</p>
|
595
|
+
<p><a class="source-toggle" href="#"
|
596
|
+
onclick="toggleCode('M000090-source');return false;">[Source]</a></p>
|
597
|
+
<div class="method-source-code" id="M000090-source">
|
598
|
+
<pre>
|
599
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 201</span>
|
600
|
+
201: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_resource</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>, <span class="ruby-identifier">headers</span>={})
|
601
|
+
202: <span class="ruby-identifier">do_get</span>(<span class="ruby-node">"/#{bucket_name}/#{resource_key}"</span>, <span class="ruby-identifier">headers</span>)
|
602
|
+
203: <span class="ruby-keyword kw">end</span>
|
603
|
+
</pre>
|
604
|
+
</div>
|
605
|
+
</div>
|
606
|
+
</div>
|
607
|
+
|
608
|
+
<div id="method-M000086" class="method-detail">
|
609
|
+
<a name="M000086"></a>
|
610
|
+
|
611
|
+
<div class="method-heading">
|
612
|
+
<a href="#M000086" class="method-signature">
|
613
|
+
<span class="method-name">list_bucket</span><span class="method-args">(bucket_name, query_params={})</span>
|
614
|
+
</a>
|
615
|
+
</div>
|
616
|
+
|
617
|
+
<div class="method-description">
|
618
|
+
<p>
|
619
|
+
List entries in a bucket.
|
620
|
+
</p>
|
621
|
+
<p>
|
622
|
+
<tt>query_params</tt>: hash of options on the bucket listing request,
|
623
|
+
passed as querystring parameters to S3 (see <a
|
624
|
+
href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01">docs.amazonwebservices.com/AmazonS3/2006-03-01</a>/).
|
625
|
+
</p>
|
626
|
+
<ul>
|
627
|
+
<li><tt>:prefix => ‘some_string‘</tt>: restrict results to keys
|
628
|
+
beginning with ‘some_string‘
|
629
|
+
|
630
|
+
</li>
|
631
|
+
<li><tt>:marker => ‘some_string‘</tt>: restict results to keys
|
632
|
+
occurring lexicographically after ‘some_string‘
|
633
|
+
|
634
|
+
</li>
|
635
|
+
<li><tt>:max_keys => 1000</tt>: return at most this number of keys (maximum
|
636
|
+
possible value is 1000)
|
637
|
+
|
638
|
+
</li>
|
639
|
+
<li><tt>:delimiter => ‘some_string‘</tt>: keys containing the
|
640
|
+
same string between prefix and the delimiter are rolled up into a
|
641
|
+
CommonPrefixes element inside the response
|
642
|
+
|
643
|
+
</li>
|
644
|
+
</ul>
|
645
|
+
<p><a class="source-toggle" href="#"
|
646
|
+
onclick="toggleCode('M000086-source');return false;">[Source]</a></p>
|
647
|
+
<div class="method-source-code" id="M000086-source">
|
648
|
+
<pre>
|
649
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 158</span>
|
650
|
+
158: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">list_bucket</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">query_params</span>={})
|
651
|
+
159: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">query_params</span>[<span class="ruby-identifier">:max_keys</span>]
|
652
|
+
160: <span class="ruby-identifier">max_keys</span> = <span class="ruby-identifier">query_params</span>[<span class="ruby-identifier">:max_keys</span>].<span class="ruby-identifier">to_i</span>
|
653
|
+
161: <span class="ruby-identifier">raise</span> <span class="ruby-constant">S33rException</span><span class="ruby-operator">::</span><span class="ruby-constant">BucketListingMaxKeysError</span>, <span class="ruby-node">"max_keys option to list bucket cannot be > #{BUCKET_LIST_MAX_MAX_KEYS}"</span> \
|
654
|
+
162: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">max_keys</span> <span class="ruby-operator">></span> <span class="ruby-constant">BUCKET_LIST_MAX_MAX_KEYS</span>
|
655
|
+
163:
|
656
|
+
164: <span class="ruby-comment cmt"># take out the max_keys parameter and move it to max-keys</span>
|
657
|
+
165: <span class="ruby-identifier">query_params</span>[<span class="ruby-value str">'max-keys'</span>] = <span class="ruby-identifier">query_params</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:max_keys</span>)
|
658
|
+
166: <span class="ruby-keyword kw">end</span>
|
659
|
+
167:
|
660
|
+
168: <span class="ruby-identifier">resp</span> = <span class="ruby-identifier">do_get</span>(<span class="ruby-node">"/#{bucket_name}"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">generate_querystring</span>(<span class="ruby-identifier">query_params</span>))
|
661
|
+
169: <span class="ruby-identifier">bucket_listing</span> = <span class="ruby-constant">BucketListing</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">resp</span>.<span class="ruby-identifier">body</span>)
|
662
|
+
170:
|
663
|
+
171: [<span class="ruby-identifier">resp</span>, <span class="ruby-identifier">bucket_listing</span>]
|
664
|
+
172: <span class="ruby-keyword kw">end</span>
|
665
|
+
</pre>
|
666
|
+
</div>
|
667
|
+
</div>
|
668
|
+
</div>
|
669
|
+
|
670
|
+
<div id="method-M000085" class="method-detail">
|
671
|
+
<a name="M000085"></a>
|
672
|
+
|
673
|
+
<div class="method-heading">
|
674
|
+
<a href="#M000085" class="method-signature">
|
675
|
+
<span class="method-name">list_buckets</span><span class="method-args">()</span>
|
676
|
+
</a>
|
677
|
+
</div>
|
678
|
+
|
679
|
+
<div class="method-description">
|
680
|
+
<p>
|
681
|
+
List all buckets.
|
682
|
+
</p>
|
683
|
+
<p><a class="source-toggle" href="#"
|
684
|
+
onclick="toggleCode('M000085-source');return false;">[Source]</a></p>
|
685
|
+
<div class="method-source-code" id="M000085-source">
|
686
|
+
<pre>
|
687
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 145</span>
|
688
|
+
145: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">list_buckets</span>
|
689
|
+
146: <span class="ruby-identifier">do_get</span>(<span class="ruby-value str">'/'</span>)
|
690
|
+
147: <span class="ruby-keyword kw">end</span>
|
691
|
+
</pre>
|
692
|
+
</div>
|
693
|
+
</div>
|
694
|
+
</div>
|
695
|
+
|
696
|
+
<div id="method-M000093" class="method-detail">
|
697
|
+
<a name="M000093"></a>
|
698
|
+
|
699
|
+
<div class="method-heading">
|
700
|
+
<a href="#M000093" class="method-signature">
|
701
|
+
<span class="method-name">put_file</span><span class="method-args">(filename, bucket_name, resource_key=nil, headers={}, options={})</span>
|
702
|
+
</a>
|
703
|
+
</div>
|
704
|
+
|
705
|
+
<div class="method-description">
|
706
|
+
<p>
|
707
|
+
Put a file onto S3.
|
708
|
+
</p>
|
709
|
+
<p>
|
710
|
+
If <tt>resource_key</tt> is nil, the filename is used as the key instead.
|
711
|
+
</p>
|
712
|
+
<p>
|
713
|
+
<tt>headers</tt> sets some headers with the request; useful if you have an
|
714
|
+
odd file type not recognised by the mimetypes library, and want to
|
715
|
+
explicitly set the Content-Type header.
|
716
|
+
</p>
|
717
|
+
<p>
|
718
|
+
<tt>options</tt> hash simplifies setting some headers with specific meaning
|
719
|
+
to S3:
|
720
|
+
</p>
|
721
|
+
<ul>
|
722
|
+
<li><tt>:render_as_attachment => true</tt>: set the Content-Disposition for
|
723
|
+
this file to "attachment" and set the default filename for saving
|
724
|
+
the file (when accessed by a web browser) to <tt>filename</tt>; this turns
|
725
|
+
the file into a download when opened in a browser, rather than trying to
|
726
|
+
render it inline.
|
727
|
+
|
728
|
+
</li>
|
729
|
+
</ul>
|
730
|
+
<p>
|
731
|
+
Note that this method uses a handle to the file, so it can be streamed in
|
732
|
+
chunks to S3.
|
733
|
+
</p>
|
734
|
+
<p><a class="source-toggle" href="#"
|
735
|
+
onclick="toggleCode('M000093-source');return false;">[Source]</a></p>
|
736
|
+
<div class="method-source-code" id="M000093-source">
|
737
|
+
<pre>
|
738
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 229</span>
|
739
|
+
229: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">put_file</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span>={}, <span class="ruby-identifier">options</span>={})
|
740
|
+
230: <span class="ruby-comment cmt"># default to the file path as the resource key if none explicitly set</span>
|
741
|
+
231: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resource_key</span>.<span class="ruby-identifier">nil?</span>
|
742
|
+
232: <span class="ruby-identifier">resource_key</span> = <span class="ruby-identifier">filename</span>
|
743
|
+
233: <span class="ruby-keyword kw">end</span>
|
744
|
+
234:
|
745
|
+
235: <span class="ruby-comment cmt"># set Content-Disposition header</span>
|
746
|
+
236: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:render_as_attachment</span>]
|
747
|
+
237: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">'Content-Disposition'</span>] = <span class="ruby-node">"attachment; filename=#{File.basename(filename)}"</span>
|
748
|
+
238: <span class="ruby-keyword kw">end</span>
|
749
|
+
239:
|
750
|
+
240: <span class="ruby-comment cmt"># content type is explicitly set in the headers, so apply to request</span>
|
751
|
+
241: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">headers</span>[<span class="ruby-identifier">:content_type</span>]
|
752
|
+
242: <span class="ruby-comment cmt"># use the first MIME type corresponding to this content type string</span>
|
753
|
+
243: <span class="ruby-comment cmt"># (MIME::Types returns an array of possible MIME types)</span>
|
754
|
+
244: <span class="ruby-identifier">mime_type</span> = <span class="ruby-constant">MIME</span><span class="ruby-operator">::</span><span class="ruby-constant">Types</span>[<span class="ruby-identifier">headers</span>[<span class="ruby-identifier">:content_type</span>]][<span class="ruby-value">0</span>]
|
755
|
+
245: <span class="ruby-keyword kw">else</span>
|
756
|
+
246: <span class="ruby-identifier">mime_type</span> = <span class="ruby-identifier">guess_mime_type</span>(<span class="ruby-identifier">filename</span>)
|
757
|
+
247: <span class="ruby-keyword kw">end</span>
|
758
|
+
248: <span class="ruby-identifier">content_type</span> = <span class="ruby-identifier">mime_type</span>.<span class="ruby-identifier">simplified</span>
|
759
|
+
249: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-identifier">content_type</span>
|
760
|
+
250: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">'Content-Transfer-Encoding'</span>] = <span class="ruby-value str">'binary'</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mime_type</span>.<span class="ruby-identifier">binary?</span>
|
761
|
+
251:
|
762
|
+
252: <span class="ruby-comment cmt"># the data we want to put (handle to file, so we can stream from it)</span>
|
763
|
+
253: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">filename</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">data</span><span class="ruby-operator">|</span>
|
764
|
+
254: <span class="ruby-comment cmt"># send the put request</span>
|
765
|
+
255: <span class="ruby-identifier">put_resource</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">headers</span>)
|
766
|
+
256: <span class="ruby-keyword kw">end</span>
|
767
|
+
257: <span class="ruby-keyword kw">end</span>
|
768
|
+
</pre>
|
769
|
+
</div>
|
770
|
+
</div>
|
771
|
+
</div>
|
772
|
+
|
773
|
+
<div id="method-M000091" class="method-detail">
|
774
|
+
<a name="M000091"></a>
|
775
|
+
|
776
|
+
<div class="method-heading">
|
777
|
+
<a href="#M000091" class="method-signature">
|
778
|
+
<span class="method-name">put_resource</span><span class="method-args">(bucket_name, resource_key, data, headers={})</span>
|
779
|
+
</a>
|
780
|
+
</div>
|
781
|
+
|
782
|
+
<div class="method-description">
|
783
|
+
<p>
|
784
|
+
Put some generic resource onto S3.
|
785
|
+
</p>
|
786
|
+
<p><a class="source-toggle" href="#"
|
787
|
+
onclick="toggleCode('M000091-source');return false;">[Source]</a></p>
|
788
|
+
<div class="method-source-code" id="M000091-source">
|
789
|
+
<pre>
|
790
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 206</span>
|
791
|
+
206: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">put_resource</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">headers</span>={})
|
792
|
+
207: <span class="ruby-identifier">do_put</span>(<span class="ruby-node">"/#{bucket_name}/"</span> <span class="ruby-operator">+</span> <span class="ruby-node">"#{CGI::escape(resource_key)}"</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">headers</span>)
|
793
|
+
208: <span class="ruby-keyword kw">end</span>
|
794
|
+
</pre>
|
795
|
+
</div>
|
796
|
+
</div>
|
797
|
+
</div>
|
798
|
+
|
799
|
+
<div id="method-M000092" class="method-detail">
|
800
|
+
<a name="M000092"></a>
|
801
|
+
|
802
|
+
<div class="method-heading">
|
803
|
+
<a href="#M000092" class="method-signature">
|
804
|
+
<span class="method-name">put_text</span><span class="method-args">(string, bucket_name, resource_key, headers={})</span>
|
805
|
+
</a>
|
806
|
+
</div>
|
807
|
+
|
808
|
+
<div class="method-description">
|
809
|
+
<p>
|
810
|
+
Put a string onto S3.
|
811
|
+
</p>
|
812
|
+
<p><a class="source-toggle" href="#"
|
813
|
+
onclick="toggleCode('M000092-source');return false;">[Source]</a></p>
|
814
|
+
<div class="method-source-code" id="M000092-source">
|
815
|
+
<pre>
|
816
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 211</span>
|
817
|
+
211: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">put_text</span>(<span class="ruby-identifier">string</span>, <span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>, <span class="ruby-identifier">headers</span>={})
|
818
|
+
212: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">"Content-Type"</span>] = <span class="ruby-value str">"text/plain"</span>
|
819
|
+
213: <span class="ruby-identifier">put_resource</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>, <span class="ruby-identifier">string</span>, <span class="ruby-identifier">headers</span>)
|
820
|
+
214: <span class="ruby-keyword kw">end</span>
|
821
|
+
</pre>
|
822
|
+
</div>
|
823
|
+
</div>
|
824
|
+
</div>
|
825
|
+
|
826
|
+
<div id="method-M000082" class="method-detail">
|
827
|
+
<a name="M000082"></a>
|
828
|
+
|
829
|
+
<div class="method-heading">
|
830
|
+
<a href="#M000082" class="method-signature">
|
831
|
+
<span class="method-name">use_ssl?</span><span class="method-args">()</span>
|
832
|
+
</a>
|
833
|
+
</div>
|
834
|
+
|
835
|
+
<div class="method-description">
|
836
|
+
<p>
|
837
|
+
Wrapper round embedded client <tt>use_ssl</tt> accessor.
|
838
|
+
</p>
|
839
|
+
<p><a class="source-toggle" href="#"
|
840
|
+
onclick="toggleCode('M000082-source');return false;">[Source]</a></p>
|
841
|
+
<div class="method-source-code" id="M000082-source">
|
842
|
+
<pre>
|
843
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 89</span>
|
844
|
+
89: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">use_ssl?</span>
|
845
|
+
90: <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">use_ssl</span>
|
846
|
+
91: <span class="ruby-keyword kw">end</span>
|
847
|
+
</pre>
|
848
|
+
</div>
|
849
|
+
</div>
|
850
|
+
</div>
|
851
|
+
|
852
|
+
<h3 class="section-bar">Protected Instance methods</h3>
|
853
|
+
|
854
|
+
<div id="method-M000100" class="method-detail">
|
855
|
+
<a name="M000100"></a>
|
856
|
+
|
857
|
+
<div class="method-heading">
|
858
|
+
<a href="#M000100" class="method-signature">
|
859
|
+
<span class="method-name">do_delete</span><span class="method-args">(path, headers={})</span>
|
860
|
+
</a>
|
861
|
+
</div>
|
862
|
+
|
863
|
+
<div class="method-description">
|
864
|
+
<p><a class="source-toggle" href="#"
|
865
|
+
onclick="toggleCode('M000100-source');return false;">[Source]</a></p>
|
866
|
+
<div class="method-source-code" id="M000100-source">
|
867
|
+
<pre>
|
868
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 291</span>
|
869
|
+
291: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">do_delete</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">headers</span>={})
|
870
|
+
292: <span class="ruby-identifier">do_request</span>(<span class="ruby-value str">'DELETE'</span>, <span class="ruby-identifier">path</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span>)
|
871
|
+
293: <span class="ruby-keyword kw">end</span>
|
872
|
+
</pre>
|
873
|
+
</div>
|
874
|
+
</div>
|
875
|
+
</div>
|
876
|
+
|
877
|
+
<div id="method-M000096" class="method-detail">
|
878
|
+
<a name="M000096"></a>
|
879
|
+
|
880
|
+
<div class="method-heading">
|
881
|
+
<a href="#M000096" class="method-signature">
|
882
|
+
<span class="method-name">do_get</span><span class="method-args">(path='/', headers={})</span>
|
883
|
+
</a>
|
884
|
+
</div>
|
885
|
+
|
886
|
+
<div class="method-description">
|
887
|
+
<p><a class="source-toggle" href="#"
|
888
|
+
onclick="toggleCode('M000096-source');return false;">[Source]</a></p>
|
889
|
+
<div class="method-source-code" id="M000096-source">
|
890
|
+
<pre>
|
891
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 275</span>
|
892
|
+
275: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">do_get</span>(<span class="ruby-identifier">path</span>=<span class="ruby-value str">'/'</span>, <span class="ruby-identifier">headers</span>={})
|
893
|
+
276: <span class="ruby-identifier">do_request</span>(<span class="ruby-value str">'GET'</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">headers</span>)
|
894
|
+
277: <span class="ruby-keyword kw">end</span>
|
895
|
+
</pre>
|
896
|
+
</div>
|
897
|
+
</div>
|
898
|
+
</div>
|
899
|
+
|
900
|
+
<div id="method-M000097" class="method-detail">
|
901
|
+
<a name="M000097"></a>
|
902
|
+
|
903
|
+
<div class="method-heading">
|
904
|
+
<a href="#M000097" class="method-signature">
|
905
|
+
<span class="method-name">do_head</span><span class="method-args">(path='/', headers={})</span>
|
906
|
+
</a>
|
907
|
+
</div>
|
908
|
+
|
909
|
+
<div class="method-description">
|
910
|
+
<p><a class="source-toggle" href="#"
|
911
|
+
onclick="toggleCode('M000097-source');return false;">[Source]</a></p>
|
912
|
+
<div class="method-source-code" id="M000097-source">
|
913
|
+
<pre>
|
914
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 279</span>
|
915
|
+
279: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">do_head</span>(<span class="ruby-identifier">path</span>=<span class="ruby-value str">'/'</span>, <span class="ruby-identifier">headers</span>={})
|
916
|
+
280: <span class="ruby-identifier">do_request</span>(<span class="ruby-value str">'HEAD'</span>, <span class="ruby-identifier">path</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span>)
|
917
|
+
281: <span class="ruby-keyword kw">end</span>
|
918
|
+
</pre>
|
919
|
+
</div>
|
920
|
+
</div>
|
921
|
+
</div>
|
922
|
+
|
923
|
+
<div id="method-M000098" class="method-detail">
|
924
|
+
<a name="M000098"></a>
|
925
|
+
|
926
|
+
<div class="method-heading">
|
927
|
+
<a href="#M000098" class="method-signature">
|
928
|
+
<span class="method-name">do_post</span><span class="method-args">(path='/', data=nil, headers={})</span>
|
929
|
+
</a>
|
930
|
+
</div>
|
931
|
+
|
932
|
+
<div class="method-description">
|
933
|
+
<p><a class="source-toggle" href="#"
|
934
|
+
onclick="toggleCode('M000098-source');return false;">[Source]</a></p>
|
935
|
+
<div class="method-source-code" id="M000098-source">
|
936
|
+
<pre>
|
937
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 283</span>
|
938
|
+
283: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">do_post</span>(<span class="ruby-identifier">path</span>=<span class="ruby-value str">'/'</span>, <span class="ruby-identifier">data</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span>={})
|
939
|
+
284: <span class="ruby-identifier">do_request</span>(<span class="ruby-value str">'POST'</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">headers</span>)
|
940
|
+
285: <span class="ruby-keyword kw">end</span>
|
941
|
+
</pre>
|
942
|
+
</div>
|
943
|
+
</div>
|
944
|
+
</div>
|
945
|
+
|
946
|
+
<div id="method-M000099" class="method-detail">
|
947
|
+
<a name="M000099"></a>
|
948
|
+
|
949
|
+
<div class="method-heading">
|
950
|
+
<a href="#M000099" class="method-signature">
|
951
|
+
<span class="method-name">do_put</span><span class="method-args">(path='/', data=nil, headers={})</span>
|
952
|
+
</a>
|
953
|
+
</div>
|
954
|
+
|
955
|
+
<div class="method-description">
|
956
|
+
<p><a class="source-toggle" href="#"
|
957
|
+
onclick="toggleCode('M000099-source');return false;">[Source]</a></p>
|
958
|
+
<div class="method-source-code" id="M000099-source">
|
959
|
+
<pre>
|
960
|
+
<span class="ruby-comment cmt"># File lib/s33r/client.rb, line 287</span>
|
961
|
+
287: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">do_put</span>(<span class="ruby-identifier">path</span>=<span class="ruby-value str">'/'</span>, <span class="ruby-identifier">data</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span>={})
|
962
|
+
288: <span class="ruby-identifier">do_request</span>(<span class="ruby-value str">'PUT'</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">headers</span>)
|
963
|
+
289: <span class="ruby-keyword kw">end</span>
|
964
|
+
</pre>
|
965
|
+
</div>
|
966
|
+
</div>
|
967
|
+
</div>
|
968
|
+
|
969
|
+
|
970
|
+
</div>
|
971
|
+
|
972
|
+
|
973
|
+
</div>
|
974
|
+
|
975
|
+
|
976
|
+
<div id="validator-badges">
|
977
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
978
|
+
</div>
|
979
|
+
|
980
|
+
</body>
|
981
|
+
</html>
|