dragonfly-s3_data_store 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/dragonfly/s3_data_store.rb +5 -1
- data/lib/dragonfly/s3_data_store/version.rb +2 -2
- data/spec/s3_data_store_spec.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d0b5dfd4515b32b598c7638932ac8f39f4b47c8
|
4
|
+
data.tar.gz: ca1cabb75ddd830e74b1486bff88d88cc405ef4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00c60f985a4fa8bff4b15b89446a86cf8770395724345cccc07f947e752339a03fe87d662f69f4cdf6777fa1dc565246ab52a17d185a9b0135d95633d62be05c
|
7
|
+
data.tar.gz: 876ba3537e4ba0a6e0f7cfc4bdcbbc8c241f338c5e9b141e8f70f10f217112dfcefa26e14e1b2480b8d0f4cfa93620fbac90ce53b0b44b8da530d9484e8cbdba
|
data/README.md
CHANGED
@@ -34,7 +34,7 @@ end
|
|
34
34
|
:region # default 'us-east-1', see Dragonfly::S3DataStore::REGIONS for options
|
35
35
|
:storage_headers # defaults to {'x-amz-acl' => 'public-read'}, can be overridden per-write - see below
|
36
36
|
:url_scheme # defaults to "http"
|
37
|
-
:url_host # defaults to "<bucket-name>.s3.amazonaws.com"
|
37
|
+
:url_host # defaults to "<bucket-name>.s3.amazonaws.com", or "s3.amazonaws.com/<bucket-name>" if not a valid subdomain
|
38
38
|
:use_iam_profile # boolean - if true, no need for access_key_id or secret_access_key
|
39
39
|
```
|
40
40
|
|
@@ -20,6 +20,8 @@ module Dragonfly
|
|
20
20
|
'sa-east-1' => 's3-sa-east-1.amazonaws.com'
|
21
21
|
}
|
22
22
|
|
23
|
+
SUBDOMAIN_PATTERN = /^[a-z0-9][a-z0-9.-]+[a-z0-9]$/
|
24
|
+
|
23
25
|
def initialize(opts={})
|
24
26
|
@bucket_name = opts[:bucket_name]
|
25
27
|
@access_key_id = opts[:access_key_id]
|
@@ -69,7 +71,9 @@ module Dragonfly
|
|
69
71
|
storage.get_object_https_url(bucket_name, uid, opts[:expires])
|
70
72
|
else
|
71
73
|
scheme = opts[:scheme] || url_scheme
|
72
|
-
host = opts[:host] || url_host ||
|
74
|
+
host = opts[:host] || url_host || (
|
75
|
+
bucket_name =~ SUBDOMAIN_PATTERN ? "#{bucket_name}.s3.amazonaws.com" : "s3.amazonaws.com/#{bucket_name}"
|
76
|
+
)
|
73
77
|
"#{scheme}://#{host}/#{uid}"
|
74
78
|
end
|
75
79
|
end
|
data/spec/s3_data_store_spec.rb
CHANGED
@@ -234,6 +234,12 @@ describe Dragonfly::S3DataStore do
|
|
234
234
|
@data_store.url_for(@uid).should == "http://#{BUCKET_NAME}.s3.amazonaws.com/some/path/on/s3"
|
235
235
|
end
|
236
236
|
|
237
|
+
it "should use path style if the bucket is not a valid S3 subdomain" do
|
238
|
+
bucket_name = BUCKET_NAME.upcase
|
239
|
+
@data_store.bucket_name = bucket_name
|
240
|
+
@data_store.url_for(@uid).should == "http://s3.amazonaws.com/#{bucket_name}/some/path/on/s3"
|
241
|
+
end
|
242
|
+
|
237
243
|
it "should use the bucket subdomain for other regions too" do
|
238
244
|
@data_store.region = 'eu-west-1'
|
239
245
|
@data_store.url_for(@uid).should == "http://#{BUCKET_NAME}.s3.amazonaws.com/some/path/on/s3"
|
@@ -241,7 +247,7 @@ describe Dragonfly::S3DataStore do
|
|
241
247
|
|
242
248
|
it "should give an expiring url" do
|
243
249
|
@data_store.url_for(@uid, :expires => 1301476942).should =~
|
244
|
-
%r{^https://#{BUCKET_NAME}\.#{@data_store.domain}/some/path/on/s3\?AWSAccessKeyId=#{@data_store.access_key_id}&Signature=[\w
|
250
|
+
%r{^https://#{BUCKET_NAME}\.#{@data_store.domain}/some/path/on/s3\?AWSAccessKeyId=#{@data_store.access_key_id}&Signature=[\w%/]+&Expires=1301476942$}
|
245
251
|
end
|
246
252
|
|
247
253
|
it "should allow for using https" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dragonfly-s3_data_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dragonfly
|