activestorage_qiniu 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67ee4adc26d85ecd394ed3304c93d2c6a79a0554ea259d11fe17bc601cee9906
|
4
|
+
data.tar.gz: b64525a1bd789219b945fe34c350a5b5797a3b9c3f98a49475ce1c18a15ea0b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e361a40ca19c76156e8a76b11fab9f2a24820f7a4ecce1c659dd4c371dd3aecdfbfdee2c8f3959abd3054567ac604c6b61daa447bd833187519bae07cb8fc1c8
|
7
|
+
data.tar.gz: a911d0288955d7b6d1bf8f11d179895ebc76fc043d1af842cbba8669a09fcd4f54c0734bc2d21119b9ffd27f105c24eba4cc890b0dfd6d93f2b9d64cddb39042
|
data/README.md
CHANGED
@@ -27,7 +27,8 @@ you can set-up qiniu storage service through the generated <tt>config/storage.ym
|
|
27
27
|
access_key: <%= ENV['QINIU_ACCESS_KEY'] %>
|
28
28
|
secret_key: <%= ENV['QINIU_SECRET_KEY'] %>
|
29
29
|
bucket: <%= ENV['QINIU_BUCKET'] %>
|
30
|
-
domain: <%= ENV['
|
30
|
+
domain: <%= ENV['QINIU_DOMAIN'] %>
|
31
|
+
protocol: <%= ENV.fetch("QINIU_PROTOCOL") { "http" } %>
|
31
32
|
```
|
32
33
|
more options. https://github.com/qiniu/ruby-sdk/blob/master/lib/qiniu/auth.rb#L49
|
33
34
|
|
@@ -28,7 +28,7 @@ module ActiveStorage
|
|
28
28
|
video_stream['width']
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def height
|
32
32
|
video_stream['height']
|
33
33
|
end
|
34
34
|
|
@@ -51,4 +51,4 @@ module ActiveStorage
|
|
51
51
|
@video_stream ||= streams.detect { |stream| stream["codec_type"] == "video" } || {}
|
52
52
|
end
|
53
53
|
end
|
54
|
-
end
|
54
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
1
3
|
module ActiveStorage
|
2
4
|
# Wraps the Qiniu Storage Service as an Active Storage service.
|
3
5
|
# See ActiveStorage::Service for the generic API documentation that applies to all services.
|
@@ -10,7 +12,8 @@ module ActiveStorage
|
|
10
12
|
# access_key: <%= ENV['QINIU_ACCESS_KEY'] %>
|
11
13
|
# secret_key: <%= ENV['QINIU_SECRET_KEY'] %>
|
12
14
|
# bucket: <%= ENV['QINIU_BUCKET'] %>
|
13
|
-
# domain: <%= ENV['
|
15
|
+
# domain: <%= ENV['QINIU_DOMAIN'] %>
|
16
|
+
# protocol: <%= ENV.fetch("QINIU_PROTOCOL") { "http" } %>
|
14
17
|
#
|
15
18
|
# more options. https://github.com/qiniu/ruby-sdk/blob/master/lib/qiniu/auth.rb#L49
|
16
19
|
#
|
@@ -29,7 +32,7 @@ module ActiveStorage
|
|
29
32
|
@protocol = (options.delete(:protocol) || 'https').to_sym
|
30
33
|
Qiniu.establish_connection! access_key: access_key,
|
31
34
|
secret_key: secret_key,
|
32
|
-
protocol: protocol,
|
35
|
+
protocol: @protocol,
|
33
36
|
**options
|
34
37
|
|
35
38
|
@upload_options = options
|
@@ -108,8 +111,9 @@ module ActiveStorage
|
|
108
111
|
attname = URI.escape "#{options[:filename] || key}"
|
109
112
|
"attname=#{attname}"
|
110
113
|
end
|
114
|
+
|
111
115
|
expires_in = options[:expires_in] || url_expires_in
|
112
|
-
url = Qiniu::Auth.authorize_download_url_2(domain, key, fop: fop, expires_in: expires_in
|
116
|
+
url = Qiniu::Auth.authorize_download_url_2(domain, key, schema: protocol, fop: fop, expires_in: expires_in)
|
113
117
|
payload[:url] = url
|
114
118
|
url
|
115
119
|
end
|