echo_uploads 0.0.11 → 0.0.13
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.rb +1 -0
- data/lib/echo_uploads/file.rb +2 -2
- data/lib/echo_uploads/filesystem_store.rb +1 -1
- data/lib/echo_uploads/s3_store.rb +22 -20
- data/lib/echo_uploads/version.rb +3 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a19cdd2aff5a28b347afebdf8935726149ef8843
|
4
|
+
data.tar.gz: c4889c53066a7d7864f88b1a0bf2753a24438c03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ab54bb35760568dc29cd84e6827c004b093adcdf2e9de2c6a180d4dfdf337b16ea9b432cd08cb01362596a8f2c248a9f64f1900b54dc7473c441a0412755de4
|
7
|
+
data.tar.gz: c3c9ea0f24c22092e1b5566c6b78d234caa9b469f65e44188a830fca18be19625f8f9d5b7073679239648048784ffc4756fbfb21193ef7250854e3511c15a339
|
data/lib/echo_uploads.rb
CHANGED
data/lib/echo_uploads/file.rb
CHANGED
@@ -85,9 +85,9 @@ module EchoUploads
|
|
85
85
|
# EchoUploads::MappedFile, which is a subclass of
|
86
86
|
# ActionDispatch::Http::UploadedFile.
|
87
87
|
if file.is_a?(ActionDispatch::Http::UploadedFile)
|
88
|
-
storage.write key, file.tempfile
|
88
|
+
storage.write key, file.tempfile, self
|
89
89
|
else
|
90
|
-
storage.write key, file
|
90
|
+
storage.write key, file, self
|
91
91
|
end
|
92
92
|
|
93
93
|
# If we mapped the files, they were temporarily written to tmp/echo_uploads.
|
@@ -1,46 +1,48 @@
|
|
1
1
|
# Uses the official Amazon Web Services SDK gem:
|
2
2
|
# gem install aws-sdk
|
3
|
+
# Incompatible with 1.x.x versions of the aws-sdk gem.
|
3
4
|
module EchoUploads
|
4
5
|
class S3Store < ::EchoUploads::AbstractStore
|
5
6
|
def delete(key)
|
6
|
-
bucket.
|
7
|
+
bucket.object(path(key)).delete
|
7
8
|
end
|
8
9
|
|
9
10
|
def exists?(key)
|
10
|
-
bucket.
|
11
|
+
bucket.object(path(key)).exists?
|
11
12
|
end
|
12
13
|
|
13
14
|
def read(key)
|
14
|
-
|
15
|
-
bucket.objects[path(key)].read { |chunk| data << chunk }
|
16
|
-
data
|
15
|
+
bucket.object(path(key)).get.body.read
|
17
16
|
end
|
18
17
|
|
19
18
|
def url(key, options = {})
|
20
|
-
options = {method: :
|
21
|
-
bucket.
|
19
|
+
options = {method: :get}.merge(options)
|
20
|
+
url_str = bucket.object(path(key)).presigned_url options.delete(:method), options
|
21
|
+
URI.parse url_str
|
22
22
|
end
|
23
23
|
|
24
|
-
def write(key, file)
|
24
|
+
def write(key, file, metadata)
|
25
25
|
file.rewind
|
26
|
-
bucket.
|
26
|
+
bucket.object(path(key)).put body: file, content_type: metadata.mime_type
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
+
def aws_config
|
32
|
+
Rails.configuration.echo_uploads.aws || {}
|
33
|
+
end
|
34
|
+
|
31
35
|
def bucket
|
32
|
-
if
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
if s3.buckets[bucket_name].nil?
|
41
|
-
s3.buckets.create bucket_name
|
36
|
+
if @bucket.nil?
|
37
|
+
bucket_name = Rails.configuration.echo_uploads.s3.bucket || raise(
|
38
|
+
'You must define config.echo_uploads.s3.bucket in your application config.'
|
39
|
+
)
|
40
|
+
@bucket = Aws::S3::Bucket.new bucket_name, aws_config
|
41
|
+
unless @bucket.exists?
|
42
|
+
raise "S3 bucket does not exist: #{bucket_name.inspect}"
|
43
|
+
end
|
42
44
|
end
|
43
|
-
|
45
|
+
@bucket
|
44
46
|
end
|
45
47
|
|
46
48
|
def folder
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jarrett Colby
|
@@ -14,16 +14,16 @@ dependencies:
|
|
14
14
|
name: mime-types
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: turn
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- lib/echo_uploads/s3_store.rb
|
59
59
|
- lib/echo_uploads/temp_file_saving.rb
|
60
60
|
- lib/echo_uploads/validation.rb
|
61
|
+
- lib/echo_uploads/version.rb
|
61
62
|
homepage: https://github.com/jarrett/echo_uploads
|
62
63
|
licenses:
|
63
64
|
- MIT
|