dragonfly-s3_data_store 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dragonfly/s3_data_store.rb +18 -2
- data/lib/dragonfly/s3_data_store/version.rb +1 -1
- data/spec/s3_data_store_spec.rb +8 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 350d8e976a1a0035972b02a7f024d982abd176e4
|
4
|
+
data.tar.gz: 1730399277815a8dce6feb6a89ed280cea18ad90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1708908b4b45d4fcbf5530a1056afe69921a3ef421b3482eb2efb16e921e354a29919395a16b5d347a0fbad43131cf941a90586bf031ab4c420816506a60c36
|
7
|
+
data.tar.gz: 84e28e6bd5f589c4f41ca2f65db364f8bdd5cc9feaeb002cb814625d6dc343d9f658376aefda1d8604d2e047b808078ee33deab946d0f0fc86da15736c17066f
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'fog/aws'
|
2
2
|
require 'dragonfly'
|
3
|
+
require 'cgi'
|
3
4
|
|
4
5
|
Dragonfly::App.register_datastore(:s3){ Dragonfly::S3DataStore }
|
5
6
|
|
@@ -135,7 +136,7 @@ module Dragonfly
|
|
135
136
|
end
|
136
137
|
|
137
138
|
def generate_uid(name)
|
138
|
-
"#{Time.now.strftime '%Y/%m/%d/%H/%M/%S'}/#{rand(1000)}/#{name
|
139
|
+
"#{Time.now.strftime '%Y/%m/%d/%H/%M/%S'}/#{rand(1000)}/#{name}"
|
139
140
|
end
|
140
141
|
|
141
142
|
def full_path(uid)
|
@@ -149,13 +150,14 @@ module Dragonfly
|
|
149
150
|
def headers_to_meta(headers)
|
150
151
|
json = headers['x-amz-meta-json']
|
151
152
|
if json && !json.empty?
|
152
|
-
Serializer.json_decode(json)
|
153
|
+
unescape_meta_values(Serializer.json_decode(json))
|
153
154
|
elsif marshal_data = headers['x-amz-meta-extra']
|
154
155
|
Utils.stringify_keys(Serializer.marshal_b64_decode(marshal_data))
|
155
156
|
end
|
156
157
|
end
|
157
158
|
|
158
159
|
def meta_to_headers(meta)
|
160
|
+
meta = escape_meta_values(meta)
|
159
161
|
{'x-amz-meta-json' => Serializer.json_encode(meta)}
|
160
162
|
end
|
161
163
|
|
@@ -170,5 +172,19 @@ module Dragonfly
|
|
170
172
|
yield
|
171
173
|
end
|
172
174
|
|
175
|
+
def escape_meta_values(meta)
|
176
|
+
meta.inject({}) {|hash, (key, value)|
|
177
|
+
hash[key] = value.is_a?(String) ? CGI.escape(value) : value
|
178
|
+
hash
|
179
|
+
}
|
180
|
+
end
|
181
|
+
|
182
|
+
def unescape_meta_values(meta)
|
183
|
+
meta.inject({}) {|hash, (key, value)|
|
184
|
+
hash[key] = value.is_a?(String) ? CGI.unescape(value) : value
|
185
|
+
hash
|
186
|
+
}
|
187
|
+
end
|
188
|
+
|
173
189
|
end
|
174
190
|
end
|
data/spec/s3_data_store_spec.rb
CHANGED
@@ -75,7 +75,7 @@ describe Dragonfly::S3DataStore do
|
|
75
75
|
it "should work ok with files with funny names" do
|
76
76
|
content.name = "A Picture with many spaces in its name (at 20:00 pm).png"
|
77
77
|
uid = @data_store.write(content)
|
78
|
-
uid.should =~ /
|
78
|
+
uid.should =~ /A Picture with many spaces in its name \(at 20:00 pm\)\.png/
|
79
79
|
new_content.update(*@data_store.read(uid))
|
80
80
|
new_content.data.should == 'eggheads'
|
81
81
|
end
|
@@ -331,6 +331,13 @@ describe Dragonfly::S3DataStore do
|
|
331
331
|
meta['some'].should == 'meta'
|
332
332
|
meta['wo'].should == 4
|
333
333
|
end
|
334
|
+
|
335
|
+
it "works with non ascii character" do
|
336
|
+
content = Dragonfly::Content.new(app, "hi", "name" => "こんにちは.txt")
|
337
|
+
uid = @data_store.write(content)
|
338
|
+
c, meta = @data_store.read(uid)
|
339
|
+
meta['name'].should == 'こんにちは.txt'
|
340
|
+
end
|
334
341
|
end
|
335
342
|
|
336
343
|
describe "fog_storage_options" 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.1.
|
4
|
+
version: 1.1.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: 2015-
|
11
|
+
date: 2015-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dragonfly
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.4.6
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: Data store for storing Dragonfly content (e.g. images) on S3
|