s33r 0.3.1 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/cli/acl_x.rb +41 -0
- data/examples/cli/logging_x.rb +20 -0
- data/{bin → examples/cli}/s3cli.rb +13 -20
- data/examples/fores33r/README +183 -0
- data/examples/fores33r/Rakefile +10 -0
- data/examples/fores33r/app/controllers/application.rb +4 -0
- data/examples/fores33r/app/controllers/browser_controller.rb +68 -0
- data/examples/fores33r/app/helpers/application_helper.rb +8 -0
- data/examples/fores33r/app/views/browser/index.rhtml +14 -0
- data/examples/fores33r/app/views/browser/show_bucket.rhtml +14 -0
- data/examples/fores33r/app/views/layouts/application.rhtml +29 -0
- data/examples/fores33r/config/boot.rb +44 -0
- data/examples/fores33r/config/database.yml +35 -0
- data/examples/fores33r/config/environment.rb +64 -0
- data/examples/fores33r/config/environments/development.rb +21 -0
- data/examples/fores33r/config/environments/production.rb +18 -0
- data/examples/fores33r/config/environments/test.rb +19 -0
- data/examples/fores33r/config/routes.rb +23 -0
- data/examples/fores33r/doc/README_FOR_APP +2 -0
- data/examples/fores33r/log/development.log +5507 -0
- 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/public/404.html +8 -0
- data/examples/fores33r/public/500.html +8 -0
- data/examples/fores33r/public/dispatch.cgi +10 -0
- data/examples/fores33r/public/dispatch.fcgi +24 -0
- data/examples/fores33r/public/dispatch.rb +10 -0
- data/examples/fores33r/public/favicon.ico +0 -0
- data/examples/fores33r/public/images/rails.png +0 -0
- data/examples/fores33r/public/javascripts/application.js +2 -0
- data/examples/fores33r/public/javascripts/controls.js +815 -0
- data/examples/fores33r/public/javascripts/dragdrop.js +913 -0
- data/examples/fores33r/public/javascripts/effects.js +958 -0
- data/examples/fores33r/public/javascripts/prototype.js +2006 -0
- data/examples/fores33r/public/robots.txt +1 -0
- data/examples/fores33r/public/stylesheets/core.css +37 -0
- data/examples/fores33r/script/about +3 -0
- data/examples/fores33r/script/breakpointer +3 -0
- data/examples/fores33r/script/console +3 -0
- data/examples/fores33r/script/destroy +3 -0
- data/examples/fores33r/script/generate +3 -0
- data/examples/fores33r/script/performance/benchmarker +3 -0
- data/examples/fores33r/script/performance/profiler +3 -0
- data/examples/fores33r/script/plugin +3 -0
- data/examples/fores33r/script/process/reaper +3 -0
- data/examples/fores33r/script/process/spawner +3 -0
- data/examples/fores33r/script/runner +3 -0
- data/examples/fores33r/script/server +3 -0
- data/examples/fores33r/test/test_helper.rb +28 -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
- data/examples/s3.yaml +11 -0
- data/html/classes/Net/HTTPGenericRequest.html +32 -32
- data/html/classes/Net/HTTPResponse.html +20 -19
- data/html/classes/S33r.html +422 -190
- data/html/classes/S33r/BucketListing.html +107 -70
- data/html/classes/S33r/Client.html +888 -414
- data/html/classes/S33r/LoggingResource.html +222 -0
- data/html/classes/S33r/NamedBucket.html +149 -150
- data/html/classes/S33r/OrderlyXmlMarkup.html +165 -0
- data/html/classes/S33r/S33rException.html +3 -0
- data/html/classes/S33r/S33rException/BucketNotLogTargetable.html +119 -0
- data/html/classes/S33r/S33rException/InvalidPermission.html +111 -0
- data/html/classes/S33r/S33rException/InvalidS3GroupType.html +111 -0
- data/html/classes/S33r/S3ACL.html +125 -0
- data/html/classes/S33r/S3ACL/ACLDoc.html +521 -0
- data/html/classes/S33r/{S3User.html → S3ACL/AmazonCustomer.html} +27 -30
- data/html/classes/S33r/S3ACL/CanonicalUser.html +212 -0
- data/html/classes/S33r/S3ACL/Grant.html +403 -0
- data/html/classes/S33r/S3ACL/Grantee.html +239 -0
- data/html/classes/S33r/S3ACL/Group.html +178 -0
- data/html/classes/S33r/S3Object.html +53 -50
- data/html/classes/S33r/Sync.html +6 -6
- data/html/classes/XML.html +4 -2
- data/html/created.rid +1 -1
- data/html/files/README_txt.html +82 -28
- data/html/files/lib/s33r/bucket_listing_rb.html +1 -8
- data/html/files/lib/s33r/builder_rb.html +108 -0
- data/html/files/lib/s33r/client_rb.html +2 -1
- data/html/files/lib/s33r/core_rb.html +2 -1
- data/html/files/lib/s33r/libxml_extensions_rb.html +1 -1
- data/html/files/lib/s33r/logging_rb.html +109 -0
- 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 +109 -0
- data/html/fr_class_index.html +12 -1
- data/html/fr_file_index.html +3 -0
- data/html/fr_method_index.html +101 -57
- data/lib/s33r/bucket_listing.rb +21 -22
- data/lib/s33r/builder.rb +20 -0
- data/lib/s33r/client.rb +240 -42
- data/lib/s33r/core.rb +106 -36
- data/lib/s33r/libxml_extensions.rb +2 -2
- data/lib/s33r/logging.rb +43 -0
- data/lib/s33r/named_bucket.rb +16 -17
- data/lib/s33r/s33r_exception.rb +11 -0
- data/lib/s33r/s33r_http.rb +2 -1
- data/lib/s33r/s3_acl.rb +337 -0
- data/test/cases/spec_acl.rb +146 -0
- data/test/cases/spec_all_buckets.rb +28 -0
- data/test/cases/spec_bucket_listing.rb +2 -2
- data/test/cases/spec_client.rb +45 -18
- data/test/cases/spec_core.rb +0 -9
- data/test/cases/spec_namedbucket.rb +3 -3
- data/test/files/acl.xml +47 -0
- data/test/files/acl_grant1.xml +7 -0
- data/test/files/acl_grant2.xml +6 -0
- data/test/files/acl_grant3.xml +6 -0
- data/test/files/acl_grant4.xml +6 -0
- data/test/files/all_buckets.xml +21 -0
- data/test/files/bucket_listing.xml +138 -1
- data/test/files/client_config.yml +0 -1
- data/test/files/logging_acl.xml +34 -0
- data/test/files/namedbucket_config.yml +1 -5
- data/test/files/namedbucket_config2.yml +1 -5
- data/test/test_setup.rb +1 -0
- metadata +132 -7
@@ -0,0 +1 @@
|
|
1
|
+
# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
|
@@ -0,0 +1,37 @@
|
|
1
|
+
* {
|
2
|
+
font-family: "Trebuchet MS", "Lucida Grande", "Verdana", arial, helvetica, sans-serif;
|
3
|
+
}
|
4
|
+
#left_pane {
|
5
|
+
float: left;
|
6
|
+
width: 20%;
|
7
|
+
background-color: #EEEEEE;
|
8
|
+
font-size: 1em;
|
9
|
+
}
|
10
|
+
#left_pane p {
|
11
|
+
padding-left: 1em;
|
12
|
+
}
|
13
|
+
#main_pane {
|
14
|
+
float: right;
|
15
|
+
width: 78%;
|
16
|
+
padding-left: 2%;
|
17
|
+
}
|
18
|
+
#main_pane h2 {
|
19
|
+
margin-top: 0em;
|
20
|
+
}
|
21
|
+
#flash {
|
22
|
+
color: green;
|
23
|
+
}
|
24
|
+
.bucket_name {
|
25
|
+
color: blue;
|
26
|
+
}
|
27
|
+
form {
|
28
|
+
border: 1px #808080 dotted;
|
29
|
+
padding: 5px;
|
30
|
+
font-size: 80%;
|
31
|
+
}
|
32
|
+
.menu_link {
|
33
|
+
font-size: 90%;
|
34
|
+
}
|
35
|
+
a {
|
36
|
+
text-decoration: none;
|
37
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
3
|
+
require 'test_help'
|
4
|
+
|
5
|
+
class Test::Unit::TestCase
|
6
|
+
# Transactional fixtures accelerate your tests by wrapping each test method
|
7
|
+
# in a transaction that's rolled back on completion. This ensures that the
|
8
|
+
# test database remains unchanged so your fixtures don't have to be reloaded
|
9
|
+
# between every test method. Fewer database queries means faster tests.
|
10
|
+
#
|
11
|
+
# Read Mike Clark's excellent walkthrough at
|
12
|
+
# http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
|
13
|
+
#
|
14
|
+
# Every Active Record database supports transactions except MyISAM tables
|
15
|
+
# in MySQL. Turn off transactional fixtures in this case; however, if you
|
16
|
+
# don't care one way or the other, switching from MyISAM to InnoDB tables
|
17
|
+
# is recommended.
|
18
|
+
self.use_transactional_fixtures = true
|
19
|
+
|
20
|
+
# Instantiated fixtures are slow, but give you @david where otherwise you
|
21
|
+
# would need people(:david). If you don't want to migrate your existing
|
22
|
+
# test cases which use the @david style and don't mind the speed hit (each
|
23
|
+
# instantiated fixtures translates to a database query per test method),
|
24
|
+
# then set this back to true.
|
25
|
+
self.use_instantiated_fixtures = false
|
26
|
+
|
27
|
+
# Add more helper methods to be used by all tests here...
|
28
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
data/examples/s3.yaml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# note you can use ERB code in this file
|
2
|
+
aws_access_key: 'yourkey'
|
3
|
+
aws_secret_access_key: 'yoursecretkey'
|
4
|
+
options:
|
5
|
+
default_expires: '12th November 2033'
|
6
|
+
use_ssl: true
|
7
|
+
dump_requests: false
|
8
|
+
default_prefix: 'someprefix'
|
9
|
+
default_bucket: 'somebucket'
|
10
|
+
from_email: 'elliot@example.com'
|
11
|
+
to_email: 'elliot@example.com'
|
@@ -157,18 +157,18 @@ to <a href="../S33r/Client.html">S33r::Client</a> constructor.
|
|
157
157
|
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
158
158
|
<div class="method-source-code" id="M000003-source">
|
159
159
|
<pre>
|
160
|
-
<span class="ruby-comment cmt"># File lib/s33r/s33r_http.rb, line
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
160
|
+
<span class="ruby-comment cmt"># File lib/s33r/s33r_http.rb, line 47</span>
|
161
|
+
47: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
162
|
+
48: <span class="ruby-identifier">str</span> = <span class="ruby-value str">"*******\n"</span> <span class="ruby-operator">+</span>
|
163
|
+
49: <span class="ruby-node">"#{self.class::METHOD} #{@path} HTTP/1.1\n"</span> <span class="ruby-operator">+</span>
|
164
|
+
50: <span class="ruby-node">"Host: #{S33r::HOST}\n"</span>
|
165
|
+
51:
|
166
|
+
52: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">each_capitalized</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>
|
167
|
+
53: <span class="ruby-identifier">str</span> <span class="ruby-operator">+=</span> <span class="ruby-node">"#{key}: #{value}\n"</span>
|
168
|
+
54: <span class="ruby-keyword kw">end</span>
|
169
|
+
55: <span class="ruby-identifier">str</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">"*******\n\n"</span>
|
170
|
+
56: <span class="ruby-identifier">str</span>
|
171
|
+
57: <span class="ruby-keyword kw">end</span>
|
172
172
|
</pre>
|
173
173
|
</div>
|
174
174
|
</div>
|
@@ -193,26 +193,26 @@ Minor alterations to original source to enable variable chunk sizes.
|
|
193
193
|
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
194
194
|
<div class="method-source-code" id="M000004-source">
|
195
195
|
<pre>
|
196
|
-
<span class="ruby-comment cmt"># File lib/s33r/s33r_http.rb, line
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
196
|
+
<span class="ruby-comment cmt"># File lib/s33r/s33r_http.rb, line 61</span>
|
197
|
+
61: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_request_with_body_stream</span>(<span class="ruby-identifier">sock</span>, <span class="ruby-identifier">ver</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">f</span>) <span class="ruby-comment cmt"># :doc:</span>
|
198
|
+
62: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"Content-Length not given and Transfer-Encoding is not `chunked'"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">content_length</span>() <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">chunked?</span>
|
199
|
+
63: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">content_type</span>()
|
200
|
+
64: <span class="ruby-identifier">warn</span> <span class="ruby-value str">'net/http: warning: Content-Type did not set; using application/x-www-form-urlencoded'</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$VERBOSE</span>
|
201
|
+
65: <span class="ruby-identifier">set_content_type</span> <span class="ruby-value str">'application/x-www-form-urlencoded'</span>
|
202
|
+
66: <span class="ruby-keyword kw">end</span>
|
203
|
+
67: <span class="ruby-ivar">@chunk_size</span> <span class="ruby-operator">||=</span> <span class="ruby-value">1024</span>
|
204
|
+
68: <span class="ruby-identifier">write_header</span> <span class="ruby-identifier">sock</span>, <span class="ruby-identifier">ver</span>, <span class="ruby-identifier">path</span>
|
205
|
+
69: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">chunked?</span>
|
206
|
+
70: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">s</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span>(<span class="ruby-ivar">@chunk_size</span>)
|
207
|
+
71: <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">sprintf</span>(<span class="ruby-value str">"%x\r\n"</span>, <span class="ruby-identifier">s</span>.<span class="ruby-identifier">length</span>) <span class="ruby-operator"><<</span> <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"\r\n"</span>)
|
208
|
+
72: <span class="ruby-keyword kw">end</span>
|
209
|
+
73: <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">write</span> <span class="ruby-value str">"0\r\n\r\n"</span>
|
210
|
+
74: <span class="ruby-keyword kw">else</span>
|
211
|
+
75: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">s</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span>(<span class="ruby-ivar">@chunk_size</span>)
|
212
|
+
76: <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">s</span>
|
213
|
+
77: <span class="ruby-keyword kw">end</span>
|
214
|
+
78: <span class="ruby-keyword kw">end</span>
|
215
|
+
79: <span class="ruby-keyword kw">end</span>
|
216
216
|
</pre>
|
217
217
|
</div>
|
218
218
|
</div>
|
@@ -152,9 +152,10 @@ Adds some convenience functions for checking response status.
|
|
152
152
|
<pre>
|
153
153
|
<span class="ruby-comment cmt"># File lib/s33r/s33r_http.rb, line 11</span>
|
154
154
|
11: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">check_s3_availability</span>
|
155
|
-
12: <span class="ruby-
|
156
|
-
13:
|
157
|
-
14:
|
155
|
+
12: <span class="ruby-keyword kw">if</span> (<span class="ruby-value">500</span><span class="ruby-operator">..</span><span class="ruby-value">503</span>).<span class="ruby-identifier">include?</span> <span class="ruby-identifier">code</span>.<span class="ruby-identifier">to_i</span>
|
156
|
+
13: <span class="ruby-identifier">raise</span> <span class="ruby-constant">S33rException</span><span class="ruby-operator">::</span><span class="ruby-constant">S3FallenOver</span>, <span class="ruby-node">"S3 has fallen over! (got a #{code} code in response)"</span>
|
157
|
+
14: <span class="ruby-keyword kw">end</span>
|
158
|
+
15: <span class="ruby-keyword kw">end</span>
|
158
159
|
</pre>
|
159
160
|
</div>
|
160
161
|
</div>
|
@@ -174,10 +175,10 @@ Adds some convenience functions for checking response status.
|
|
174
175
|
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
175
176
|
<div class="method-source-code" id="M000008-source">
|
176
177
|
<pre>
|
177
|
-
<span class="ruby-comment cmt"># File lib/s33r/s33r_http.rb, line
|
178
|
-
|
179
|
-
|
180
|
-
|
178
|
+
<span class="ruby-comment cmt"># File lib/s33r/s33r_http.rb, line 25</span>
|
179
|
+
25: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">not_found</span>
|
180
|
+
26: <span class="ruby-identifier">code</span> = <span class="ruby-value str">'404'</span>
|
181
|
+
27: <span class="ruby-keyword kw">end</span>
|
181
182
|
</pre>
|
182
183
|
</div>
|
183
184
|
</div>
|
@@ -197,10 +198,10 @@ Adds some convenience functions for checking response status.
|
|
197
198
|
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
198
199
|
<div class="method-source-code" id="M000006-source">
|
199
200
|
<pre>
|
200
|
-
<span class="ruby-comment cmt"># File lib/s33r/s33r_http.rb, line
|
201
|
-
|
202
|
-
|
203
|
-
|
201
|
+
<span class="ruby-comment cmt"># File lib/s33r/s33r_http.rb, line 17</span>
|
202
|
+
17: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ok?</span>
|
203
|
+
18: <span class="ruby-identifier">success</span>
|
204
|
+
19: <span class="ruby-keyword kw">end</span>
|
204
205
|
</pre>
|
205
206
|
</div>
|
206
207
|
</div>
|
@@ -220,10 +221,10 @@ Adds some convenience functions for checking response status.
|
|
220
221
|
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
221
222
|
<div class="method-source-code" id="M000007-source">
|
222
223
|
<pre>
|
223
|
-
<span class="ruby-comment cmt"># File lib/s33r/s33r_http.rb, line
|
224
|
-
|
225
|
-
|
226
|
-
|
224
|
+
<span class="ruby-comment cmt"># File lib/s33r/s33r_http.rb, line 21</span>
|
225
|
+
21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">success</span>
|
226
|
+
22: <span class="ruby-identifier">code</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'200'</span>
|
227
|
+
23: <span class="ruby-keyword kw">end</span>
|
227
228
|
</pre>
|
228
229
|
</div>
|
229
230
|
</div>
|
@@ -243,10 +244,10 @@ Adds some convenience functions for checking response status.
|
|
243
244
|
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
244
245
|
<div class="method-source-code" id="M000009-source">
|
245
246
|
<pre>
|
246
|
-
<span class="ruby-comment cmt"># File lib/s33r/s33r_http.rb, line
|
247
|
-
|
248
|
-
|
249
|
-
|
247
|
+
<span class="ruby-comment cmt"># File lib/s33r/s33r_http.rb, line 29</span>
|
248
|
+
29: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
249
|
+
30: <span class="ruby-identifier">body</span>
|
250
|
+
31: <span class="ruby-keyword kw">end</span>
|
250
251
|
</pre>
|
251
252
|
</div>
|
252
253
|
</div>
|
data/html/classes/S33r.html
CHANGED
@@ -62,10 +62,18 @@
|
|
62
62
|
<a href="../files/lib/s33r/client_rb.html">
|
63
63
|
lib/s33r/client.rb
|
64
64
|
</a>
|
65
|
+
<br />
|
66
|
+
<a href="../files/lib/s33r/builder_rb.html">
|
67
|
+
lib/s33r/builder.rb
|
68
|
+
</a>
|
65
69
|
<br />
|
66
70
|
<a href="../files/lib/s33r/bucket_listing_rb.html">
|
67
71
|
lib/s33r/bucket_listing.rb
|
68
72
|
</a>
|
73
|
+
<br />
|
74
|
+
<a href="../files/lib/s33r/s3_acl_rb.html">
|
75
|
+
lib/s33r/s3_acl.rb
|
76
|
+
</a>
|
69
77
|
<br />
|
70
78
|
<a href="../files/lib/s33r/core_rb.html">
|
71
79
|
lib/s33r/core.rb
|
@@ -78,6 +86,10 @@
|
|
78
86
|
<a href="../files/lib/s33r/s33r_exception_rb.html">
|
79
87
|
lib/s33r/s33r_exception.rb
|
80
88
|
</a>
|
89
|
+
<br />
|
90
|
+
<a href="../files/lib/s33r/logging_rb.html">
|
91
|
+
lib/s33r/logging.rb
|
92
|
+
</a>
|
81
93
|
<br />
|
82
94
|
</td>
|
83
95
|
</tr>
|
@@ -130,11 +142,16 @@ their license:
|
|
130
142
|
<a href="#M000049">generate_querystring</a>
|
131
143
|
<a href="#M000043">generate_signature</a>
|
132
144
|
<a href="#M000047">guess_mime_type</a>
|
133
|
-
<a href="#
|
145
|
+
<a href="#M000056">keys_to_symbols</a>
|
134
146
|
<a href="#M000045">metadata_headers</a>
|
135
|
-
<a href="#
|
136
|
-
<a href="#
|
137
|
-
<a href="#M000050">
|
147
|
+
<a href="#M000057">parse_expiry</a>
|
148
|
+
<a href="#M000058">remove_namespace</a>
|
149
|
+
<a href="#M000050">s3_acl_path</a>
|
150
|
+
<a href="#M000055">s3_authenticated_url</a>
|
151
|
+
<a href="#M000051">s3_logging_path</a>
|
152
|
+
<a href="#M000054">s3_path</a>
|
153
|
+
<a href="#M000053">s3_public_url</a>
|
154
|
+
<a href="#M000052">s3_url</a>
|
138
155
|
</div>
|
139
156
|
</div>
|
140
157
|
|
@@ -156,12 +173,14 @@ their license:
|
|
156
173
|
<h3 class="section-bar">Classes and Modules</h3>
|
157
174
|
|
158
175
|
Module <a href="S33r/S33rException.html" class="link">S33r::S33rException</a><br />
|
176
|
+
Module <a href="S33r/S3ACL.html" class="link">S33r::S3ACL</a><br />
|
159
177
|
Module <a href="S33r/Sync.html" class="link">S33r::Sync</a><br />
|
160
178
|
Class <a href="S33r/BucketListing.html" class="link">S33r::BucketListing</a><br />
|
161
179
|
Class <a href="S33r/Client.html" class="link">S33r::Client</a><br />
|
180
|
+
Class <a href="S33r/LoggingResource.html" class="link">S33r::LoggingResource</a><br />
|
162
181
|
Class <a href="S33r/NamedBucket.html" class="link">S33r::NamedBucket</a><br />
|
182
|
+
Class <a href="S33r/OrderlyXmlMarkup.html" class="link">S33r::OrderlyXmlMarkup</a><br />
|
163
183
|
Class <a href="S33r/S3Object.html" class="link">S33r::S3Object</a><br />
|
164
|
-
Class <a href="S33r/S3User.html" class="link">S33r::S3User</a><br />
|
165
184
|
|
166
185
|
</div>
|
167
186
|
|
@@ -196,7 +215,8 @@ Class <a href="S33r/S3User.html" class="link">S33r::S3User</a><br />
|
|
196
215
|
<td class="context-item-value">1048576</td>
|
197
216
|
<td width="3em"> </td>
|
198
217
|
<td class="context-item-desc">
|
199
|
-
Size of each chunk (in bytes) to be sent per request when putting files
|
218
|
+
Size of each chunk (in bytes) to be sent per request when putting files
|
219
|
+
(1Mb).
|
200
220
|
|
201
221
|
</td>
|
202
222
|
</tr>
|
@@ -229,6 +249,11 @@ Headers which must be included with every request to S3.
|
|
229
249
|
<td class="context-item-name">CANNED_ACLS</td>
|
230
250
|
<td>=</td>
|
231
251
|
<td class="context-item-value">['private', 'public-read', 'public-read-write', 'authenticated-read']</td>
|
252
|
+
<td width="3em"> </td>
|
253
|
+
<td class="context-item-desc">
|
254
|
+
Canned ACLs made available by S3.
|
255
|
+
|
256
|
+
</td>
|
232
257
|
</tr>
|
233
258
|
<tr class="top-aligned-row context-row">
|
234
259
|
<td class="context-item-name">METHOD_VERBS</td>
|
@@ -261,6 +286,61 @@ Default number of seconds an authenticated URL will last for (15 minutes).
|
|
261
286
|
|
262
287
|
</td>
|
263
288
|
</tr>
|
289
|
+
<tr class="top-aligned-row context-row">
|
290
|
+
<td class="context-item-name">RESPONSE_NAMESPACE_URI</td>
|
291
|
+
<td>=</td>
|
292
|
+
<td class="context-item-value">"http://s3.amazonaws.com/doc/2006-03-01/"</td>
|
293
|
+
<td width="3em"> </td>
|
294
|
+
<td class="context-item-desc">
|
295
|
+
The namespace used for response body <a href="XML.html">XML</a> documents.
|
296
|
+
|
297
|
+
</td>
|
298
|
+
</tr>
|
299
|
+
<tr class="top-aligned-row context-row">
|
300
|
+
<td class="context-item-name">PERMISSIONS</td>
|
301
|
+
<td>=</td>
|
302
|
+
<td class="context-item-value">{ :read => 'READ', # permission to read :write => 'WRITE', # permission to write :read_acl => 'READ_ACP', # permission to read ACL settings :all => 'FULL_CONTROL'</td>
|
303
|
+
<td width="3em"> </td>
|
304
|
+
<td class="context-item-desc">
|
305
|
+
Permissions which can be set within a <Grant> (see <a
|
306
|
+
href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/UsingPermissions.html">docs.amazonwebservices.com/AmazonS3/2006-03-01/UsingPermissions.html</a>).
|
307
|
+
|
308
|
+
<p>
|
309
|
+
NB I’ve missed out the WRITE_ACP permission as this is functionally
|
310
|
+
equivalent to FULL_CONTROL.
|
311
|
+
</p>
|
312
|
+
</td>
|
313
|
+
</tr>
|
314
|
+
<tr class="top-aligned-row context-row">
|
315
|
+
<td class="context-item-name">NAMESPACE</td>
|
316
|
+
<td>=</td>
|
317
|
+
<td class="context-item-value">'xsi'</td>
|
318
|
+
<td width="3em"> </td>
|
319
|
+
<td class="context-item-desc">
|
320
|
+
Used for generating ACL <a href="XML.html">XML</a> documents.
|
321
|
+
|
322
|
+
</td>
|
323
|
+
</tr>
|
324
|
+
<tr class="top-aligned-row context-row">
|
325
|
+
<td class="context-item-name">NAMESPACE_URI</td>
|
326
|
+
<td>=</td>
|
327
|
+
<td class="context-item-value">'http://www.w3.org/2001/XMLSchema-instance'</td>
|
328
|
+
</tr>
|
329
|
+
<tr class="top-aligned-row context-row">
|
330
|
+
<td class="context-item-name">GRANTEE_TYPES</td>
|
331
|
+
<td>=</td>
|
332
|
+
<td class="context-item-value">{ :amazon_customer => 'AmazonCustomerByEmail', :canonical_user => 'CanonicalUser', :group => 'Group'</td>
|
333
|
+
</tr>
|
334
|
+
<tr class="top-aligned-row context-row">
|
335
|
+
<td class="context-item-name">S3_GROUP_TYPES</td>
|
336
|
+
<td>=</td>
|
337
|
+
<td class="context-item-value">{ :all_users => 'global/AllUsers', :authenticated_users => 'global/AuthenticatedUsers', :log_delivery => 's3/LogDelivery'</td>
|
338
|
+
</tr>
|
339
|
+
<tr class="top-aligned-row context-row">
|
340
|
+
<td class="context-item-name">GROUP_ACL_URI_BASE</td>
|
341
|
+
<td>=</td>
|
342
|
+
<td class="context-item-value">'http://acs.amazonaws.com/groups/'</td>
|
343
|
+
</tr>
|
264
344
|
</table>
|
265
345
|
</div>
|
266
346
|
</div>
|
@@ -274,31 +354,107 @@ Default number of seconds an authenticated URL will last for (15 minutes).
|
|
274
354
|
<div id="methods">
|
275
355
|
<h3 class="section-bar">Public Class methods</h3>
|
276
356
|
|
277
|
-
<div id="method-
|
278
|
-
<a name="
|
357
|
+
<div id="method-M000056" class="method-detail">
|
358
|
+
<a name="M000056"></a>
|
279
359
|
|
280
360
|
<div class="method-heading">
|
281
|
-
<a href="#
|
361
|
+
<a href="#M000056" class="method-signature">
|
282
362
|
<span class="method-name">keys_to_symbols</span><span class="method-args">(hsh)</span>
|
283
363
|
</a>
|
284
364
|
</div>
|
285
365
|
|
286
366
|
<div class="method-description">
|
287
367
|
<p>
|
288
|
-
Turn keys in a hash hsh into symbols.
|
289
|
-
|
368
|
+
Turn keys in a hash <tt>hsh</tt> into symbols.
|
369
|
+
</p>
|
370
|
+
<p>
|
371
|
+
Returns a hash with ‘symbolised’ keys.
|
290
372
|
</p>
|
291
373
|
<p><a class="source-toggle" href="#"
|
292
|
-
onclick="toggleCode('
|
293
|
-
<div class="method-source-code" id="
|
374
|
+
onclick="toggleCode('M000056-source');return false;">[Source]</a></p>
|
375
|
+
<div class="method-source-code" id="M000056-source">
|
376
|
+
<pre>
|
377
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 255</span>
|
378
|
+
255: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">S33r</span>.<span class="ruby-identifier">keys_to_symbols</span>(<span class="ruby-identifier">hsh</span>)
|
379
|
+
256: <span class="ruby-identifier">symbolised</span> = <span class="ruby-identifier">hsh</span>.<span class="ruby-identifier">inject</span>({}) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">symbolised</span>, <span class="ruby-identifier">key_value</span><span class="ruby-operator">|</span>
|
380
|
+
257: <span class="ruby-identifier">symbolised</span>.<span class="ruby-identifier">merge</span>({<span class="ruby-identifier">key_value</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">to_sym</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">key_value</span>[<span class="ruby-value">1</span>]})
|
381
|
+
258: <span class="ruby-keyword kw">end</span>
|
382
|
+
259: <span class="ruby-identifier">symbolised</span>
|
383
|
+
260: <span class="ruby-keyword kw">end</span>
|
384
|
+
</pre>
|
385
|
+
</div>
|
386
|
+
</div>
|
387
|
+
</div>
|
388
|
+
|
389
|
+
<div id="method-M000057" class="method-detail">
|
390
|
+
<a name="M000057"></a>
|
391
|
+
|
392
|
+
<div class="method-heading">
|
393
|
+
<a href="#M000057" class="method-signature">
|
394
|
+
<span class="method-name">parse_expiry</span><span class="method-args">(expires)</span>
|
395
|
+
</a>
|
396
|
+
</div>
|
397
|
+
|
398
|
+
<div class="method-description">
|
399
|
+
<p>
|
400
|
+
Parse an expiry date to seconds since the epoch.
|
401
|
+
</p>
|
402
|
+
<p>
|
403
|
+
<tt>expires</tt> can be set to ‘forever’ to get a time 20 years
|
404
|
+
in the future; ‘default’ to use the current time +
|
405
|
+
DEFAULT_EXPIRY_SECS; or to a specific date (parseable by ParseDate); or to
|
406
|
+
an integer representing seconds since the epoch.
|
407
|
+
</p>
|
408
|
+
<p>
|
409
|
+
TODO: testing for this
|
410
|
+
</p>
|
411
|
+
<p><a class="source-toggle" href="#"
|
412
|
+
onclick="toggleCode('M000057-source');return false;">[Source]</a></p>
|
413
|
+
<div class="method-source-code" id="M000057-source">
|
414
|
+
<pre>
|
415
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 270</span>
|
416
|
+
270: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">S33r</span>.<span class="ruby-identifier">parse_expiry</span>(<span class="ruby-identifier">expires</span>)
|
417
|
+
271: <span class="ruby-identifier">base_expires</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">to_i</span>
|
418
|
+
272: <span class="ruby-keyword kw">if</span> <span class="ruby-value str">'forever'</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">expires</span>
|
419
|
+
273: <span class="ruby-comment cmt"># 20 years (same as forever in computer terms)</span>
|
420
|
+
274: <span class="ruby-identifier">expires</span> = <span class="ruby-identifier">base_expires</span> <span class="ruby-operator">+</span> (<span class="ruby-value">60</span> <span class="ruby-operator">*</span> <span class="ruby-value">60</span> <span class="ruby-operator">*</span> <span class="ruby-value">24</span> <span class="ruby-operator">*</span> <span class="ruby-value">365.25</span> <span class="ruby-operator">*</span> <span class="ruby-value">20</span>).<span class="ruby-identifier">to_i</span>
|
421
|
+
275: <span class="ruby-keyword kw">elsif</span> <span class="ruby-value str">'default'</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">expires</span>
|
422
|
+
276: <span class="ruby-comment cmt"># default to DEFAULT_EXPIRY_SECS seconds from now if expires not set</span>
|
423
|
+
277: <span class="ruby-identifier">expires</span> = <span class="ruby-identifier">base_expires</span> <span class="ruby-operator">+</span> <span class="ruby-constant">DEFAULT_EXPIRY_SECS</span>
|
424
|
+
278: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">expires</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
|
425
|
+
279: <span class="ruby-identifier">datetime_parts</span> = <span class="ruby-constant">ParseDate</span>.<span class="ruby-identifier">parsedate</span>(<span class="ruby-identifier">expires</span>)
|
426
|
+
280: <span class="ruby-identifier">expires</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">gm</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">datetime_parts</span>).<span class="ruby-identifier">to_i</span>
|
427
|
+
281: <span class="ruby-keyword kw">end</span>
|
428
|
+
282: <span class="ruby-identifier">expires</span>
|
429
|
+
283: <span class="ruby-keyword kw">end</span>
|
430
|
+
</pre>
|
431
|
+
</div>
|
432
|
+
</div>
|
433
|
+
</div>
|
434
|
+
|
435
|
+
<div id="method-M000058" class="method-detail">
|
436
|
+
<a name="M000058"></a>
|
437
|
+
|
438
|
+
<div class="method-heading">
|
439
|
+
<a href="#M000058" class="method-signature">
|
440
|
+
<span class="method-name">remove_namespace</span><span class="method-args">(xml_in)</span>
|
441
|
+
</a>
|
442
|
+
</div>
|
443
|
+
|
444
|
+
<div class="method-description">
|
445
|
+
<p>
|
446
|
+
Remove the namespace declaration from S3 <a href="XML.html">XML</a>
|
447
|
+
response bodies (libxml isn’t fond of it).
|
448
|
+
</p>
|
449
|
+
<p><a class="source-toggle" href="#"
|
450
|
+
onclick="toggleCode('M000058-source');return false;">[Source]</a></p>
|
451
|
+
<div class="method-source-code" id="M000058-source">
|
294
452
|
<pre>
|
295
|
-
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
219: <span class="ruby-identifier">symbolised</span>
|
301
|
-
220: <span class="ruby-keyword kw">end</span>
|
453
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 287</span>
|
454
|
+
287: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">S33r</span>.<span class="ruby-identifier">remove_namespace</span>(<span class="ruby-identifier">xml_in</span>)
|
455
|
+
288: <span class="ruby-identifier">namespace</span> = <span class="ruby-constant">RESPONSE_NAMESPACE_URI</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">'/'</span>, <span class="ruby-value str">'\/'</span>)
|
456
|
+
289: <span class="ruby-identifier">xml_in</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-node">/ xmlns="#{namespace}"/</span>, <span class="ruby-value str">''</span>)
|
457
|
+
290: <span class="ruby-keyword kw">end</span>
|
302
458
|
</pre>
|
303
459
|
</div>
|
304
460
|
</div>
|
@@ -318,29 +474,29 @@ Turn keys in a hash hsh into symbols. Returns a hash with
|
|
318
474
|
<div class="method-description">
|
319
475
|
<p>
|
320
476
|
Build the headers required with every S3 request (Date and Content-Type);
|
321
|
-
options hash can contain extra header settings
|
322
|
-
|
477
|
+
options hash can contain extra header settings; +:date+ and +:content_type+
|
478
|
+
are required headers, and set to defaults if not supplied
|
323
479
|
</p>
|
324
480
|
<p><a class="source-toggle" href="#"
|
325
481
|
onclick="toggleCode('M000044-source');return false;">[Source]</a></p>
|
326
482
|
<div class="method-source-code" id="M000044-source">
|
327
483
|
<pre>
|
328
|
-
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
484
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 144</span>
|
485
|
+
144: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_default_headers</span>(<span class="ruby-identifier">headers</span>, <span class="ruby-identifier">options</span>={})
|
486
|
+
145: <span class="ruby-comment cmt"># set the default headers required by AWS</span>
|
487
|
+
146: <span class="ruby-identifier">missing_headers</span> = <span class="ruby-constant">REQUIRED_HEADERS</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">keys</span>
|
488
|
+
147:
|
489
|
+
148: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">missing_headers</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value str">'Content-Type'</span>)
|
490
|
+
149: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:content_type</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">''</span>
|
491
|
+
150: <span class="ruby-keyword kw">end</span>
|
492
|
+
151:
|
493
|
+
152: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">missing_headers</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value str">'Date'</span>)
|
494
|
+
153: <span class="ruby-identifier">date</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:date</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
495
|
+
154: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">'Date'</span>] = <span class="ruby-identifier">date</span>.<span class="ruby-identifier">httpdate</span>
|
496
|
+
155: <span class="ruby-keyword kw">end</span>
|
497
|
+
156:
|
498
|
+
157: <span class="ruby-identifier">headers</span>
|
499
|
+
158: <span class="ruby-keyword kw">end</span>
|
344
500
|
</pre>
|
345
501
|
</div>
|
346
502
|
</div>
|
@@ -363,12 +519,12 @@ Ensure that a bucket_name is well-formed (no leading or trailing slash).
|
|
363
519
|
onclick="toggleCode('M000048-source');return false;">[Source]</a></p>
|
364
520
|
<div class="method-source-code" id="M000048-source">
|
365
521
|
<pre>
|
366
|
-
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
522
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 190</span>
|
523
|
+
190: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">bucket_name_valid?</span>(<span class="ruby-identifier">bucket_name</span>)
|
524
|
+
191: <span class="ruby-keyword kw">if</span> (<span class="ruby-value str">'/'</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">bucket_name</span>[<span class="ruby-value">0</span>,<span class="ruby-value">1</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'/'</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">bucket_name</span>[<span class="ruby-value">-1</span>,<span class="ruby-value">1</span>])
|
525
|
+
192: <span class="ruby-identifier">raise</span> <span class="ruby-constant">S33rException</span><span class="ruby-operator">::</span><span class="ruby-constant">MalformedBucketName</span>, <span class="ruby-value str">"Bucket name cannot have a leading or trailing slash"</span>
|
526
|
+
193: <span class="ruby-keyword kw">end</span>
|
527
|
+
194: <span class="ruby-keyword kw">end</span>
|
372
528
|
</pre>
|
373
529
|
</div>
|
374
530
|
</div>
|
@@ -391,16 +547,16 @@ Add a canned ACL setter header.
|
|
391
547
|
onclick="toggleCode('M000046-source');return false;">[Source]</a></p>
|
392
548
|
<div class="method-source-code" id="M000046-source">
|
393
549
|
<pre>
|
394
|
-
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
550
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 171</span>
|
551
|
+
171: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">canned_acl_header</span>(<span class="ruby-identifier">canned_acl</span>, <span class="ruby-identifier">headers</span>={})
|
552
|
+
172: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">canned_acl</span>.<span class="ruby-identifier">nil?</span>
|
553
|
+
173: <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">CANNED_ACLS</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">canned_acl</span>)
|
554
|
+
174: <span class="ruby-identifier">raise</span> <span class="ruby-constant">S33rException</span><span class="ruby-operator">::</span><span class="ruby-constant">UnsupportedCannedACL</span>, <span class="ruby-node">"The canned ACL #{canned_acl} is not supported"</span>
|
555
|
+
175: <span class="ruby-keyword kw">end</span>
|
556
|
+
176: <span class="ruby-identifier">headers</span>[<span class="ruby-constant">AWS_HEADER_PREFIX</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'acl'</span>] = <span class="ruby-identifier">canned_acl</span>
|
557
|
+
177: <span class="ruby-keyword kw">end</span>
|
558
|
+
178: <span class="ruby-identifier">headers</span>
|
559
|
+
179: <span class="ruby-keyword kw">end</span>
|
404
560
|
</pre>
|
405
561
|
</div>
|
406
562
|
</div>
|
@@ -423,22 +579,22 @@ Get the value for the AWS authentication header.
|
|
423
579
|
onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
|
424
580
|
<div class="method-source-code" id="M000042-source">
|
425
581
|
<pre>
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
582
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 118</span>
|
583
|
+
118: <span class="ruby-keyword kw">def</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>, <span class="ruby-identifier">aws_access_key</span>, <span class="ruby-identifier">aws_secret_access_key</span>)
|
584
|
+
119: <span class="ruby-identifier">raise</span> <span class="ruby-constant">S33rException</span><span class="ruby-operator">::</span><span class="ruby-constant">MethodNotAvailable</span>, <span class="ruby-value str">"Method %s not available"</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">method</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>)
|
585
|
+
120:
|
586
|
+
121: <span class="ruby-comment cmt"># check the headers needed for authentication have been set</span>
|
587
|
+
122: <span class="ruby-identifier">missing_headers</span> = <span class="ruby-constant">REQUIRED_HEADERS</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">keys</span>
|
588
|
+
123: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">missing_headers</span>.<span class="ruby-identifier">empty?</span>)
|
589
|
+
124: <span class="ruby-identifier">raise</span> <span class="ruby-constant">S33rException</span><span class="ruby-operator">::</span><span class="ruby-constant">MissingRequiredHeaders</span>,
|
590
|
+
125: <span class="ruby-value str">"Headers required for AWS auth value are missing: "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">missing_headers</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">', '</span>)
|
591
|
+
126: <span class="ruby-keyword kw">end</span>
|
592
|
+
127:
|
593
|
+
128: <span class="ruby-comment cmt"># get the AWS header</span>
|
594
|
+
129: <span class="ruby-identifier">canonical_string</span> = <span class="ruby-identifier">generate_canonical_string</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">headers</span>)
|
595
|
+
130: <span class="ruby-identifier">signature</span> = <span class="ruby-identifier">generate_signature</span>(<span class="ruby-identifier">aws_secret_access_key</span>, <span class="ruby-identifier">canonical_string</span>)
|
596
|
+
131: <span class="ruby-constant">AWS_AUTH_HEADER_VALUE</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">aws_access_key</span>, <span class="ruby-identifier">signature</span>]
|
597
|
+
132: <span class="ruby-keyword kw">end</span>
|
442
598
|
</pre>
|
443
599
|
</div>
|
444
600
|
</div>
|
@@ -462,46 +618,48 @@ sample code.
|
|
462
618
|
onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
|
463
619
|
<div class="method-source-code" id="M000041-source">
|
464
620
|
<pre>
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
621
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 75</span>
|
622
|
+
75: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">generate_canonical_string</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">headers</span>={}, <span class="ruby-identifier">expires</span>=<span class="ruby-keyword kw">nil</span>)
|
623
|
+
76: <span class="ruby-identifier">interesting_headers</span> = {}
|
624
|
+
77: <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>
|
625
|
+
78: <span class="ruby-identifier">lk</span> = <span class="ruby-identifier">key</span>.<span class="ruby-identifier">downcase</span>
|
626
|
+
79: <span class="ruby-keyword kw">if</span> (<span class="ruby-constant">INTERESTING_HEADERS</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">lk</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">lk</span> <span class="ruby-operator">=~</span> <span class="ruby-node">/^#{AWS_HEADER_PREFIX}/o</span>)
|
627
|
+
80: <span class="ruby-identifier">interesting_headers</span>[<span class="ruby-identifier">lk</span>] = <span class="ruby-identifier">value</span>
|
628
|
+
81: <span class="ruby-keyword kw">end</span>
|
629
|
+
82: <span class="ruby-keyword kw">end</span>
|
630
|
+
83:
|
631
|
+
84: <span class="ruby-comment cmt"># These fields get empty strings if they don't exist.</span>
|
632
|
+
85: <span class="ruby-identifier">interesting_headers</span>[<span class="ruby-value str">'content-type'</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">''</span>
|
633
|
+
86: <span class="ruby-identifier">interesting_headers</span>[<span class="ruby-value str">'content-md5'</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">''</span>
|
634
|
+
87:
|
635
|
+
88: <span class="ruby-comment cmt"># If you're using expires for query string auth, then it trumps date.</span>
|
636
|
+
89: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">expires</span>.<span class="ruby-identifier">nil?</span>
|
637
|
+
90: <span class="ruby-identifier">interesting_headers</span>[<span class="ruby-value str">'date'</span>] = <span class="ruby-identifier">expires</span>
|
638
|
+
91: <span class="ruby-keyword kw">end</span>
|
639
|
+
92:
|
640
|
+
93: <span class="ruby-identifier">buf</span> = <span class="ruby-node">"#{method}\n"</span>
|
641
|
+
94: <span class="ruby-identifier">interesting_headers</span>.<span class="ruby-identifier">sort</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>[<span class="ruby-value">0</span>] <span class="ruby-operator"><=></span> <span class="ruby-identifier">b</span>[<span class="ruby-value">0</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>
|
642
|
+
95: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key</span> <span class="ruby-operator">=~</span> <span class="ruby-node">/^#{AWS_HEADER_PREFIX}/o</span>
|
643
|
+
96: <span class="ruby-identifier">buf</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{key}:#{value}\n"</span>
|
644
|
+
97: <span class="ruby-keyword kw">else</span>
|
645
|
+
98: <span class="ruby-identifier">buf</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{value}\n"</span>
|
646
|
+
99: <span class="ruby-keyword kw">end</span>
|
647
|
+
100: <span class="ruby-keyword kw">end</span>
|
648
|
+
101:
|
649
|
+
102: <span class="ruby-comment cmt"># Ignore everything after the question mark...</span>
|
650
|
+
103: <span class="ruby-identifier">buf</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\?.*$/</span>, <span class="ruby-value str">''</span>)
|
651
|
+
104:
|
652
|
+
105: <span class="ruby-comment cmt"># ...unless there is an acl, logging or torrent parameter</span>
|
653
|
+
106: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/[&?]acl($|&|=)/</span>
|
654
|
+
107: <span class="ruby-identifier">buf</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">'?acl'</span>
|
655
|
+
108: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">path</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/[&?]torrent($|&|=)/</span>
|
656
|
+
109: <span class="ruby-identifier">buf</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">'?torrent'</span>
|
657
|
+
110: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">path</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/[&?]logging($|&|=)/</span>
|
658
|
+
111: <span class="ruby-identifier">buf</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">'?logging'</span>
|
659
|
+
112: <span class="ruby-keyword kw">end</span>
|
660
|
+
113:
|
661
|
+
114: <span class="ruby-identifier">buf</span>
|
662
|
+
115: <span class="ruby-keyword kw">end</span>
|
505
663
|
</pre>
|
506
664
|
</div>
|
507
665
|
</div>
|
@@ -525,14 +683,14 @@ variable can be a string or symbol.
|
|
525
683
|
onclick="toggleCode('M000049-source');return false;">[Source]</a></p>
|
526
684
|
<div class="method-source-code" id="M000049-source">
|
527
685
|
<pre>
|
528
|
-
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
686
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 198</span>
|
687
|
+
198: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">generate_querystring</span>(<span class="ruby-identifier">pairs</span>={})
|
688
|
+
199: <span class="ruby-identifier">str</span> = <span class="ruby-value str">''</span>
|
689
|
+
200: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pairs</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
690
|
+
201: <span class="ruby-identifier">str</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">"?"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">pairs</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-node">"#{key}=#{CGI::escape(value.to_s)}"</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">'&'</span>)
|
691
|
+
202: <span class="ruby-keyword kw">end</span>
|
692
|
+
203: <span class="ruby-identifier">str</span>
|
693
|
+
204: <span class="ruby-keyword kw">end</span>
|
536
694
|
</pre>
|
537
695
|
</div>
|
538
696
|
</div>
|
@@ -556,11 +714,11 @@ sha1 sum, and then base64 encoding it.
|
|
556
714
|
onclick="toggleCode('M000043-source');return false;">[Source]</a></p>
|
557
715
|
<div class="method-source-code" id="M000043-source">
|
558
716
|
<pre>
|
559
|
-
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
717
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 136</span>
|
718
|
+
136: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">generate_signature</span>(<span class="ruby-identifier">aws_secret_access_key</span>, <span class="ruby-identifier">str</span>)
|
719
|
+
137: <span class="ruby-identifier">digest</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">HMAC</span><span class="ruby-operator">::</span><span class="ruby-identifier">digest</span>(<span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">Digest</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">"SHA1"</span>), <span class="ruby-identifier">aws_secret_access_key</span>, <span class="ruby-identifier">str</span>)
|
720
|
+
138: <span class="ruby-constant">Base64</span>.<span class="ruby-identifier">encode64</span>(<span class="ruby-identifier">digest</span>).<span class="ruby-identifier">strip</span>
|
721
|
+
139: <span class="ruby-keyword kw">end</span>
|
564
722
|
</pre>
|
565
723
|
</div>
|
566
724
|
</div>
|
@@ -584,12 +742,12 @@ guessed, "text/plain" is used.
|
|
584
742
|
onclick="toggleCode('M000047-source');return false;">[Source]</a></p>
|
585
743
|
<div class="method-source-code" id="M000047-source">
|
586
744
|
<pre>
|
587
|
-
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
745
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 183</span>
|
746
|
+
183: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">guess_mime_type</span>(<span class="ruby-identifier">file_name</span>)
|
747
|
+
184: <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">type_for</span>(<span class="ruby-identifier">file_name</span>)[<span class="ruby-value">0</span>]
|
748
|
+
185: <span class="ruby-identifier">mime_type</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">MIME</span><span class="ruby-operator">::</span><span class="ruby-constant">Types</span>[<span class="ruby-value str">'text/plain'</span>][<span class="ruby-value">0</span>]
|
749
|
+
186: <span class="ruby-identifier">mime_type</span>
|
750
|
+
187: <span class="ruby-keyword kw">end</span>
|
593
751
|
</pre>
|
594
752
|
</div>
|
595
753
|
</div>
|
@@ -606,56 +764,90 @@ guessed, "text/plain" is used.
|
|
606
764
|
|
607
765
|
<div class="method-description">
|
608
766
|
<p>
|
609
|
-
Add metadata headers, correctly prefixing them first.
|
610
|
-
|
767
|
+
Add metadata headers, correctly prefixing them first.
|
768
|
+
</p>
|
769
|
+
<p>
|
770
|
+
Returns headers with the metadata headers appended.
|
611
771
|
</p>
|
612
772
|
<p><a class="source-toggle" href="#"
|
613
773
|
onclick="toggleCode('M000045-source');return false;">[Source]</a></p>
|
614
774
|
<div class="method-source-code" id="M000045-source">
|
615
775
|
<pre>
|
616
|
-
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
776
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 163</span>
|
777
|
+
163: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">metadata_headers</span>(<span class="ruby-identifier">headers</span>, <span class="ruby-identifier">metadata</span>={})
|
778
|
+
164: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">metadata</span>.<span class="ruby-identifier">empty?</span>
|
779
|
+
165: <span class="ruby-identifier">metadata</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">headers</span>[<span class="ruby-constant">METADATA_PREFIX</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span> }
|
780
|
+
166: <span class="ruby-keyword kw">end</span>
|
781
|
+
167: <span class="ruby-identifier">headers</span>
|
782
|
+
168: <span class="ruby-keyword kw">end</span>
|
623
783
|
</pre>
|
624
784
|
</div>
|
625
785
|
</div>
|
626
786
|
</div>
|
627
787
|
|
628
|
-
<div id="method-
|
629
|
-
<a name="
|
788
|
+
<div id="method-M000050" class="method-detail">
|
789
|
+
<a name="M000050"></a>
|
630
790
|
|
631
791
|
<div class="method-heading">
|
632
|
-
<a href="#
|
633
|
-
<span class="method-name">
|
792
|
+
<a href="#M000050" class="method-signature">
|
793
|
+
<span class="method-name">s3_acl_path</span><span class="method-args">(bucket_name, resource_key)</span>
|
794
|
+
</a>
|
795
|
+
</div>
|
796
|
+
|
797
|
+
<div class="method-description">
|
798
|
+
<p>
|
799
|
+
Return the location of the ACL for a resource.
|
800
|
+
</p>
|
801
|
+
<p><a class="source-toggle" href="#"
|
802
|
+
onclick="toggleCode('M000050-source');return false;">[Source]</a></p>
|
803
|
+
<div class="method-source-code" id="M000050-source">
|
804
|
+
<pre>
|
805
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 207</span>
|
806
|
+
207: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">s3_acl_path</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>)
|
807
|
+
208: <span class="ruby-identifier">s3_path</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">"?acl"</span>
|
808
|
+
209: <span class="ruby-keyword kw">end</span>
|
809
|
+
</pre>
|
810
|
+
</div>
|
811
|
+
</div>
|
812
|
+
</div>
|
813
|
+
|
814
|
+
<div id="method-M000055" class="method-detail">
|
815
|
+
<a name="M000055"></a>
|
816
|
+
|
817
|
+
<div class="method-heading">
|
818
|
+
<a href="#M000055" class="method-signature">
|
819
|
+
<span class="method-name">s3_authenticated_url</span><span class="method-args">(aws_access_key, aws_secret_access_key, bucket_name, resource_key, expires=nil)</span>
|
634
820
|
</a>
|
635
821
|
</div>
|
636
822
|
|
637
823
|
<div class="method-description">
|
638
824
|
<p>
|
639
825
|
Generate a get-able URL for an S3 resource key which passes authentication
|
640
|
-
in querystring.
|
826
|
+
in querystring.
|
827
|
+
</p>
|
828
|
+
<p>
|
829
|
+
int <tt>expires</tt>: when the URL expires (seconds since the epoch); NB
|
830
|
+
you can use <a href="S33r.html#M000057">S33r.parse_expiry</a> to generate a
|
831
|
+
suitable value from a string.
|
641
832
|
</p>
|
642
833
|
<p><a class="source-toggle" href="#"
|
643
|
-
onclick="toggleCode('
|
644
|
-
<div class="method-source-code" id="
|
834
|
+
onclick="toggleCode('M000055-source');return false;">[Source]</a></p>
|
835
|
+
<div class="method-source-code" id="M000055-source">
|
645
836
|
<pre>
|
646
|
-
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
837
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 238</span>
|
838
|
+
238: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">s3_authenticated_url</span>(<span class="ruby-identifier">aws_access_key</span>, <span class="ruby-identifier">aws_secret_access_key</span>, <span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>,
|
839
|
+
239: <span class="ruby-identifier">expires</span>=<span class="ruby-keyword kw">nil</span>)
|
840
|
+
240: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">s3_path</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>)
|
841
|
+
241: <span class="ruby-identifier">expires</span> = <span class="ruby-constant">S33r</span>.<span class="ruby-identifier">parse_expiry</span>(<span class="ruby-identifier">expires</span>)
|
842
|
+
242:
|
843
|
+
243: <span class="ruby-identifier">canonical_string</span> = <span class="ruby-identifier">generate_canonical_string</span>(<span class="ruby-value str">'GET'</span>, <span class="ruby-identifier">path</span>, {}, <span class="ruby-identifier">expires</span>)
|
844
|
+
244: <span class="ruby-identifier">signature</span> = <span class="ruby-identifier">generate_signature</span>(<span class="ruby-identifier">aws_secret_access_key</span>, <span class="ruby-identifier">canonical_string</span>)
|
845
|
+
245:
|
846
|
+
246: <span class="ruby-identifier">querystring</span> = <span class="ruby-identifier">generate_querystring</span>({ <span class="ruby-value str">'Signature'</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">signature</span>, <span class="ruby-value str">'Expires'</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">expires</span>,
|
847
|
+
247: <span class="ruby-value str">'AWSAccessKeyId'</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">aws_access_key</span> })
|
848
|
+
248:
|
849
|
+
249: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s3_url</span>(<span class="ruby-identifier">path</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">querystring</span>
|
850
|
+
250: <span class="ruby-keyword kw">end</span>
|
659
851
|
</pre>
|
660
852
|
</div>
|
661
853
|
</div>
|
@@ -666,63 +858,103 @@ in querystring. int expires: when the URL expires (seconds since the epoch)
|
|
666
858
|
|
667
859
|
<div class="method-heading">
|
668
860
|
<a href="#M000051" class="method-signature">
|
669
|
-
<span class="method-name">
|
861
|
+
<span class="method-name">s3_logging_path</span><span class="method-args">(bucket_name, resource_key)</span>
|
670
862
|
</a>
|
671
863
|
</div>
|
672
864
|
|
673
865
|
<div class="method-description">
|
674
866
|
<p>
|
675
|
-
|
867
|
+
Return the location of the logging definition for a resource.
|
676
868
|
</p>
|
677
869
|
<p><a class="source-toggle" href="#"
|
678
870
|
onclick="toggleCode('M000051-source');return false;">[Source]</a></p>
|
679
871
|
<div class="method-source-code" id="M000051-source">
|
680
872
|
<pre>
|
681
|
-
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line
|
682
|
-
|
683
|
-
|
684
|
-
|
873
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 212</span>
|
874
|
+
212: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">s3_logging_path</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>)
|
875
|
+
213: <span class="ruby-identifier">s3_path</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">"?logging"</span>
|
876
|
+
214: <span class="ruby-keyword kw">end</span>
|
685
877
|
</pre>
|
686
878
|
</div>
|
687
879
|
</div>
|
688
880
|
</div>
|
689
881
|
|
690
|
-
<div id="method-
|
691
|
-
<a name="
|
882
|
+
<div id="method-M000054" class="method-detail">
|
883
|
+
<a name="M000054"></a>
|
692
884
|
|
693
885
|
<div class="method-heading">
|
694
|
-
<a href="#
|
695
|
-
<span class="method-name">
|
886
|
+
<a href="#M000054" class="method-signature">
|
887
|
+
<span class="method-name">s3_path</span><span class="method-args">(bucket_name, resource_key)</span>
|
696
888
|
</a>
|
697
889
|
</div>
|
698
890
|
|
699
891
|
<div class="method-description">
|
700
892
|
<p>
|
701
|
-
|
702
|
-
slash between arguments (only if it’s not already there).
|
893
|
+
Returns the path for this bucket and key.
|
703
894
|
</p>
|
704
895
|
<p><a class="source-toggle" href="#"
|
705
|
-
onclick="toggleCode('
|
706
|
-
<div class="method-source-code" id="
|
896
|
+
onclick="toggleCode('M000054-source');return false;">[Source]</a></p>
|
897
|
+
<div class="method-source-code" id="M000054-source">
|
898
|
+
<pre>
|
899
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 228</span>
|
900
|
+
228: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">s3_path</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>)
|
901
|
+
229: <span class="ruby-identifier">path</span> = <span class="ruby-value str">'/'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">bucket_name</span>
|
902
|
+
230: <span class="ruby-identifier">path</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">'/'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">resource_key</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-value str">''</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">resource_key</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">resource_key</span>.<span class="ruby-identifier">nil?</span>
|
903
|
+
231: <span class="ruby-identifier">path</span>
|
904
|
+
232: <span class="ruby-keyword kw">end</span>
|
905
|
+
</pre>
|
906
|
+
</div>
|
907
|
+
</div>
|
908
|
+
</div>
|
909
|
+
|
910
|
+
<div id="method-M000053" class="method-detail">
|
911
|
+
<a name="M000053"></a>
|
912
|
+
|
913
|
+
<div class="method-heading">
|
914
|
+
<a href="#M000053" class="method-signature">
|
915
|
+
<span class="method-name">s3_public_url</span><span class="method-args">(bucket_name, resource_key='')</span>
|
916
|
+
</a>
|
917
|
+
</div>
|
918
|
+
|
919
|
+
<div class="method-description">
|
920
|
+
<p>
|
921
|
+
Public readable URL for a bucket and resource.
|
922
|
+
</p>
|
923
|
+
<p><a class="source-toggle" href="#"
|
924
|
+
onclick="toggleCode('M000053-source');return false;">[Source]</a></p>
|
925
|
+
<div class="method-source-code" id="M000053-source">
|
926
|
+
<pre>
|
927
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 222</span>
|
928
|
+
222: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">s3_public_url</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>=<span class="ruby-value str">''</span>)
|
929
|
+
223: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">s3_path</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>)
|
930
|
+
224: <span class="ruby-identifier">s3_url</span>(<span class="ruby-identifier">path</span>)
|
931
|
+
225: <span class="ruby-keyword kw">end</span>
|
932
|
+
</pre>
|
933
|
+
</div>
|
934
|
+
</div>
|
935
|
+
</div>
|
936
|
+
|
937
|
+
<div id="method-M000052" class="method-detail">
|
938
|
+
<a name="M000052"></a>
|
939
|
+
|
940
|
+
<div class="method-heading">
|
941
|
+
<a href="#M000052" class="method-signature">
|
942
|
+
<span class="method-name">s3_url</span><span class="method-args">(path)</span>
|
943
|
+
</a>
|
944
|
+
</div>
|
945
|
+
|
946
|
+
<div class="method-description">
|
947
|
+
<p>
|
948
|
+
Prepend scheme and HOST to path.
|
949
|
+
</p>
|
950
|
+
<p><a class="source-toggle" href="#"
|
951
|
+
onclick="toggleCode('M000052-source');return false;">[Source]</a></p>
|
952
|
+
<div class="method-source-code" id="M000052-source">
|
707
953
|
<pre>
|
708
|
-
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
178:
|
713
|
-
179: <span class="ruby-comment cmt"># string index where the scheme of the URL (xxxx://) ends</span>
|
714
|
-
180: <span class="ruby-identifier">scheme_ends_at</span> = (<span class="ruby-identifier">url_end</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/:\/\//</span>)
|
715
|
-
181: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">scheme_ends_at</span>.<span class="ruby-identifier">nil?</span>
|
716
|
-
182: <span class="ruby-identifier">scheme_ends_at</span> = <span class="ruby-identifier">scheme_ends_at</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
|
717
|
-
183: <span class="ruby-identifier">url_start</span> = <span class="ruby-identifier">url_end</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">scheme_ends_at</span>]
|
718
|
-
184: <span class="ruby-identifier">url_end</span> = <span class="ruby-identifier">url_end</span>[(<span class="ruby-identifier">scheme_ends_at</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>)<span class="ruby-operator">..</span><span class="ruby-value">-1</span>]
|
719
|
-
185: <span class="ruby-keyword kw">end</span>
|
720
|
-
186:
|
721
|
-
187: <span class="ruby-comment cmt"># replace any multiple forward slashes (except those in the scheme)</span>
|
722
|
-
188: <span class="ruby-identifier">url_end</span> = <span class="ruby-identifier">url_end</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\/{2,}/</span>, <span class="ruby-value str">'/'</span>)
|
723
|
-
189:
|
724
|
-
190: <span class="ruby-identifier">url_start</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">url_end</span>
|
725
|
-
191: <span class="ruby-keyword kw">end</span>
|
954
|
+
<span class="ruby-comment cmt"># File lib/s33r/core.rb, line 217</span>
|
955
|
+
217: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">s3_url</span>(<span class="ruby-identifier">path</span>)
|
956
|
+
218: <span class="ruby-value str">"http://"</span> <span class="ruby-operator">+</span> <span class="ruby-constant">HOST</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">path</span>
|
957
|
+
219: <span class="ruby-keyword kw">end</span>
|
726
958
|
</pre>
|
727
959
|
</div>
|
728
960
|
</div>
|