activestorage_upyun 0.1.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -0
- data/lib/active_storage/service/upyun_service.rb +10 -4
- data/lib/activestorage_upyun/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c680c39e020941f01c261047212c41150da91e13b77f15bd1aff293da29e8364
|
4
|
+
data.tar.gz: ca532178dacc85e8bcee53c41aa839346e47a7d19ace9653ee54cc8b96af2c41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df0da59f40e289b381facf3c375b8c9cc772c7a9645b5d1a72ae39c0b13cf10d50983ff88c405ee620ac510962d4ce04392cd34be4fbb556334ae6a46df7aed3
|
7
|
+
data.tar.gz: 7c1847ea2006b2ce278955ab4e2c20176f2d24053ac0e413a2902120a7118461118b40626825aad873c1f4727fdc34718118e289a07748043f896dc5fece258a
|
data/README.md
CHANGED
@@ -26,5 +26,30 @@ Set up activestorage service:
|
|
26
26
|
config.active_storage.service = :upyun
|
27
27
|
```
|
28
28
|
|
29
|
+
Use for image url
|
30
|
+
|
31
|
+
```erb
|
32
|
+
<%= image_tag @user.avatar.service_url %>
|
33
|
+
```
|
34
|
+
|
35
|
+
Or add thumb version named `webpw200`
|
36
|
+
|
37
|
+
```erb
|
38
|
+
<%= image_tag @user.avatar.service_url(params: {process: 'webpw200'}) %>
|
39
|
+
```
|
40
|
+
|
41
|
+
thumb version use `!` as default identifier, if you want to use `_` as identifier, you can add `identifier` option
|
42
|
+
|
43
|
+
```yml
|
44
|
+
upyun:
|
45
|
+
service: Upyun
|
46
|
+
bucket: <%= ENV['UPYUUN_BUCKET'] %>
|
47
|
+
operator: <%= ENV['UPYUUN_OPERATOR'] %>
|
48
|
+
password: <%= ENV['UPYUUN_PASSWORD'] %>
|
49
|
+
host: <%= ENV['UPYUN_HOST'] %>
|
50
|
+
folder: <%= ENV['UPYUN_FOLDER'] %>
|
51
|
+
identifier: _
|
52
|
+
```
|
53
|
+
|
29
54
|
## License
|
30
55
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -21,6 +21,7 @@ module ActiveStorage
|
|
21
21
|
#
|
22
22
|
class Service::UpyunService < Service
|
23
23
|
ENDPOINT = 'http://v0.api.upyun.com'
|
24
|
+
IDENTIFIER = '!'
|
24
25
|
|
25
26
|
attr_reader :upyun, :bucket, :operator, :password, :host, :folder, :upload_options
|
26
27
|
|
@@ -71,9 +72,9 @@ module ActiveStorage
|
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
74
|
-
def url(key,
|
75
|
+
def url(key, expires_in:, filename:, content_type:, disposition:, params: {})
|
75
76
|
instrument :url, key: key do |payload|
|
76
|
-
url = url_for(key)
|
77
|
+
url = url_for(key, params: params)
|
77
78
|
payload[:url] = url
|
78
79
|
url
|
79
80
|
end
|
@@ -116,8 +117,13 @@ module ActiveStorage
|
|
116
117
|
|
117
118
|
private
|
118
119
|
|
119
|
-
def url_for(key)
|
120
|
-
[@host, @folder, key].join('/')
|
120
|
+
def url_for(key, params: {})
|
121
|
+
url = [@host, @folder, key].join('/')
|
122
|
+
return url if params.blank?
|
123
|
+
process = params.delete(:process)
|
124
|
+
identifier = @upload_options[:identifier] || IDENTIFIER
|
125
|
+
url = [url, process].join(identifier) if process
|
126
|
+
url
|
121
127
|
end
|
122
128
|
|
123
129
|
def path_for(key)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activestorage_upyun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- doabit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activestorage
|