carrierwave-qiniu 1.1.3 → 1.1.4
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/CHANGELOG.md +7 -1
- data/README.md +3 -3
- data/lib/carrierwave-qiniu/version.rb +1 -1
- data/lib/carrierwave/qiniu/url.rb +21 -19
- data/lib/carrierwave/storage/qiniu.rb +25 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2969c9d64f8400822f65b783381740a8a0626774
|
4
|
+
data.tar.gz: 28b9f1f27b77d1325345e10abc750f127c6f5129
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d11c7c6cf9982b4afbe13ebd5751e54070bfd7dcb011d8b1d61223037942dbfe8ae46842464ccc0cbab5fcfc57da42d237262a32a20a76ffd68a4c9e5b78fc8d
|
7
|
+
data.tar.gz: 4dc11efc08ada1f331d57c49d5b0622514147f8339b165274e6b22c9626761063ffd932411cfad1babee078066981878771aeead0dde2602d41a3699c6109827
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
|
2
2
|
## CHANGE LOG
|
3
3
|
|
4
|
+
### v1.1.4
|
5
|
+
|
6
|
+
- 支持带样式的私有链接
|
7
|
+
|
8
|
+
https://github.com/huobazi/carrierwave-qiniu/pull/80
|
9
|
+
|
4
10
|
### v1.1.3
|
5
11
|
|
6
12
|
新增参数 qiniu_delete_after_days
|
@@ -19,7 +25,7 @@ https://github.com/huobazi/carrierwave-qiniu/pull/78
|
|
19
25
|
### v1.1.0
|
20
26
|
|
21
27
|
- Require carrierwave ~> 1.0
|
22
|
-
|
28
|
+
|
23
29
|
https://github.com/huobazi/carrierwave-qiniu/pull/73
|
24
30
|
|
25
31
|
### v1.0.1
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Carrierwave::Qiniu
|
2
2
|
|
3
|
-
[](http://badge.fury.io/rb/carrierwave-qiniu)
|
4
4
|
|
5
5
|
This gem adds storage support for [Qiniu](http://qiniutek.com) to [Carrierwave](https://github.com/jnicklas/carrierwave)
|
6
6
|
|
@@ -10,7 +10,7 @@ example: https://github.com/huobazi/carrierwave-qiniu-example
|
|
10
10
|
|
11
11
|
Add the following to your application's Gemfile:
|
12
12
|
|
13
|
-
gem 'carrierwave-qiniu', '~> 1.1.
|
13
|
+
gem 'carrierwave-qiniu', '~> 1.1.4'
|
14
14
|
# If you need to use locales other than English
|
15
15
|
gem 'carrierwave-i18n'
|
16
16
|
|
@@ -20,7 +20,7 @@ And then execute:
|
|
20
20
|
|
21
21
|
Or install it yourself as:
|
22
22
|
|
23
|
-
$ gem install carrierwave-qiniu -v 1.1.
|
23
|
+
$ gem install carrierwave-qiniu -v 1.1.4
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module CarrierWave
|
2
2
|
module Qiniu
|
3
3
|
module Url
|
4
|
+
|
5
|
+
##
|
4
6
|
# === Examples:
|
5
7
|
#
|
6
8
|
# avatar.url(:version)
|
@@ -10,33 +12,33 @@ module CarrierWave
|
|
10
12
|
def url(*args)
|
11
13
|
return super if args.empty?
|
12
14
|
|
13
|
-
#
|
14
|
-
|
15
|
-
return unless url
|
15
|
+
# return nil if blank
|
16
|
+
return if file.blank?
|
16
17
|
|
18
|
+
# Usage: avatar.url(style: 'imageView/0/w/200')
|
17
19
|
if args.first.is_a? Hash
|
18
|
-
|
19
|
-
|
20
|
-
return "#{url}?#{options[:style]}"
|
20
|
+
if style = args.first[:style]
|
21
|
+
return file.url(style: style)
|
21
22
|
end
|
22
23
|
else
|
23
|
-
|
24
|
+
# Usage: avatar.url(version, options)
|
24
25
|
version = args.first.to_sym
|
25
|
-
if styles.
|
26
|
+
if styles.has_key? version
|
26
27
|
options = args.last
|
27
28
|
|
28
|
-
# TODO: handle private url
|
29
29
|
# Usage: avatar.url(:version, inline: true)
|
30
|
-
if options.present? && options.is_a?(Hash) && options[:inline] && styles[version]
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
30
|
+
url_options = if options.present? && options.is_a?(Hash) && options[:inline] && styles[version]
|
31
|
+
{ style: styles[version] }
|
32
|
+
else
|
33
|
+
# global inline mode
|
34
|
+
if self.class.qiniu_style_inline && styles[version]
|
35
|
+
{ style: styles[version] }
|
36
|
+
else
|
37
|
+
# Usage: avatar.url(:version)
|
38
|
+
{ version: version }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
return file.url(url_options) if url_options
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
@@ -131,8 +131,19 @@ module CarrierWave
|
|
131
131
|
@path
|
132
132
|
end
|
133
133
|
|
134
|
-
|
135
|
-
|
134
|
+
##
|
135
|
+
# Return qiniu URl, maybe with style
|
136
|
+
#
|
137
|
+
# === Parameters
|
138
|
+
# [options (Hash)] optional options hash, 图片样式 { version: :thumb } 或者 { style: "imageView2/1/w/200" }
|
139
|
+
#
|
140
|
+
# === Returns
|
141
|
+
#
|
142
|
+
# [String]
|
143
|
+
#
|
144
|
+
def url(options = {})
|
145
|
+
path = options.present? ? path_with_style(options) : @path
|
146
|
+
qiniu_connection.download_url(path)
|
136
147
|
end
|
137
148
|
|
138
149
|
def store(file)
|
@@ -219,6 +230,18 @@ module CarrierWave
|
|
219
230
|
@file_info ||= qiniu_connection.stat(@path)
|
220
231
|
end
|
221
232
|
|
233
|
+
def path_with_style(options)
|
234
|
+
return @path unless options
|
235
|
+
|
236
|
+
if version = options[:version]
|
237
|
+
"#{@path}#{@uploader.class.qiniu_style_separator}#{version}"
|
238
|
+
elsif style = options[:style]
|
239
|
+
"#{@path}?#{style}"
|
240
|
+
else
|
241
|
+
@path
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
222
245
|
end
|
223
246
|
|
224
247
|
def store!(file)
|