echo_uploads 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/lib/echo_uploads/file.rb +4 -0
- data/lib/echo_uploads/filesystem_store.rb +1 -1
- data/lib/echo_uploads/model.rb +6 -0
- data/lib/echo_uploads/s3_store.rb +15 -8
- 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: 75454542bb29646f3b17fd5d72d86a1d6e8802ab
|
4
|
+
data.tar.gz: 9fd264f1b0e217f776afd90820ad68d2db645306
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8526cdc620a6311028ac8a54a509b38d78058e93f226d7c32a89470a620ef0edd38f419b54fa57a9611a7157171e90070fa3b04392d0f6254457d5017207278b
|
7
|
+
data.tar.gz: 0f44dea04658d84809108fb9edde1f45c2d6a4860f060b9f2f305de25b5962c5ab5b5511ea9706cb6ddd38949f1283866ccb8ee7acd1bc2401ae3c3ec1b4324a
|
data/lib/echo_uploads/file.rb
CHANGED
data/lib/echo_uploads/model.rb
CHANGED
@@ -178,6 +178,12 @@ module EchoUploads
|
|
178
178
|
send("#{attr}_tmp_metadata").present?
|
179
179
|
end
|
180
180
|
|
181
|
+
# Define the read_x method. Delegates to the #read method of the store (e.g.
|
182
|
+
# FilesystemStore).
|
183
|
+
define_method("read_#{attr}") do
|
184
|
+
echo_uploads_map_metadata(attr, options, &:read)
|
185
|
+
end
|
186
|
+
|
181
187
|
# Define the association with the metadata model.
|
182
188
|
if options[:multiple]
|
183
189
|
has_many("#{attr}_metadatas".to_sym,
|
@@ -3,26 +3,27 @@
|
|
3
3
|
module EchoUploads
|
4
4
|
class S3Store < ::EchoUploads::AbstractStore
|
5
5
|
def delete(key)
|
6
|
-
bucket.objects[key].delete
|
6
|
+
bucket.objects[path(key)].delete
|
7
7
|
end
|
8
8
|
|
9
9
|
def exists?(key)
|
10
|
-
bucket.objects[key].exists?
|
10
|
+
bucket.objects[path(key)].exists?
|
11
11
|
end
|
12
12
|
|
13
13
|
def read(key)
|
14
14
|
data = ''
|
15
|
-
bucket.objects[key].read { |chunk| data << chunk }
|
15
|
+
bucket.objects[path(key)].read { |chunk| data << chunk }
|
16
16
|
data
|
17
17
|
end
|
18
18
|
|
19
19
|
def url(key, options = {})
|
20
20
|
options = {method: :read}.merge(options)
|
21
|
-
bucket.objects[key].url_for options.delete(:method), options
|
21
|
+
bucket.objects[path(key)].url_for options.delete(:method), options
|
22
22
|
end
|
23
23
|
|
24
24
|
def write(key, file)
|
25
|
-
|
25
|
+
file.rewind
|
26
|
+
bucket.objects[path(key)].write file
|
26
27
|
end
|
27
28
|
|
28
29
|
private
|
@@ -43,9 +44,15 @@ module EchoUploads
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def folder
|
46
|
-
Rails.configuration.echo_uploads.s3.folder
|
47
|
-
|
48
|
-
|
47
|
+
if Rails.configuration.respond_to?(:echo_uploads) and Rails.configuration.echo_uploads.s3.folder
|
48
|
+
Rails.configuration.echo_uploads.s3.folder
|
49
|
+
else
|
50
|
+
::File.join 'echo_uploads', Rails.env
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def path(key)
|
55
|
+
::File.join folder, key
|
49
56
|
end
|
50
57
|
end
|
51
58
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: echo_uploads
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jarrett Colby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|