paperclip-storage-aliyun 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/lib/aliyun/connection.rb +4 -0
- data/lib/paperclip/storage/aliyun.rb +4 -4
- data/paperclip-storage-aliyun.gemspec +1 -1
- data/spec/aliyun_spec.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f45c4d78df19bc94d47a95df25828e4dc748bb3
|
4
|
+
data.tar.gz: eef3b058ae65e4bac93803f72a2117a90d22cf83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '00985474f87c15bcc703e40e10db405b4f63a58348f84be779b05e4651bf303862b2457b8f3f27fb74f8550e31d422771d178eb370a30cd55b88be57e6650b5a'
|
7
|
+
data.tar.gz: cab455de6ebfbcfc7e5edfede4344774bb47381e42faad45af2c5549704a22bbbb7226fc71c54f7828419a09ff3b9257e7a1c609e3a9d6b2d2ab20138271dbd1
|
data/README.md
CHANGED
@@ -22,7 +22,8 @@ Paperclip::Attachment.default_options[:aliyun] = {
|
|
22
22
|
access_key: 'VAUI2q7Tc6yTh1jr3kBsEUzZ84gEa2',
|
23
23
|
bucket: 'xx-test',
|
24
24
|
data_center: 'hangzhou',
|
25
|
-
internal: false
|
25
|
+
internal: false,
|
26
|
+
protocol: 'https'
|
26
27
|
}
|
27
28
|
```
|
28
29
|
Then, in the model which defines the attachment, specify your storage and other options, for example:
|
@@ -56,8 +57,9 @@ Please note the values above are all strings, not symbols. You could still make
|
|
56
57
|
access_key: 'your_access_key_secret',
|
57
58
|
bucket: 'your_bucket',
|
58
59
|
data_center: 'your_data_center',
|
59
|
-
internal: false
|
60
|
+
internal: false,
|
61
|
+
protocol: 'https'
|
60
62
|
}
|
61
63
|
```
|
62
64
|
|
63
|
-
2. Run `bundle exec rspec spec`.
|
65
|
+
2. Run `bundle exec rspec spec`.
|
data/lib/aliyun/connection.rb
CHANGED
@@ -18,6 +18,8 @@ module Aliyun
|
|
18
18
|
# The alias host
|
19
19
|
attr_reader :aliyun_alias_host
|
20
20
|
|
21
|
+
attr_reader :aliyun_protocol
|
22
|
+
|
21
23
|
# Initialize the OSS connection
|
22
24
|
#
|
23
25
|
# @param [Hash] An options to specify connection details
|
@@ -33,6 +35,8 @@ module Aliyun
|
|
33
35
|
@aliyun_access_id = options[:access_id]
|
34
36
|
@aliyun_access_key = options[:access_key]
|
35
37
|
@aliyun_bucket = options[:bucket]
|
38
|
+
@aliyun_protocol = options[:protocol] || 'http'
|
39
|
+
|
36
40
|
|
37
41
|
@aliyun_upload_host = "#{@aliyun_bucket}.#{get_endpoint(options)}"
|
38
42
|
@aliyun_internal_host = "#{@aliyun_bucket}.#{get_endpoint(options.merge(internal: true))}"
|
@@ -17,19 +17,19 @@ module Paperclip
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def aliyun_upload_url(style = default_style)
|
20
|
-
"
|
20
|
+
"#{oss_connection.aliyun_protocol}://#{oss_connection.aliyun_upload_host}/#{path(style).sub(%r{\A/}, '')}"
|
21
21
|
end
|
22
22
|
|
23
23
|
def aliyun_internal_url(style = default_style)
|
24
|
-
"
|
24
|
+
"#{oss_connection.aliyun_protocol}://#{oss_connection.aliyun_internal_host}/#{path(style).sub(%r{\A/}, '')}"
|
25
25
|
end
|
26
26
|
|
27
27
|
def aliyun_external_url(style = default_style)
|
28
|
-
"
|
28
|
+
"#{oss_connection.aliyun_protocol}://#{oss_connection.aliyun_external_host}/#{path(style).sub(%r{\A/}, '')}"
|
29
29
|
end
|
30
30
|
|
31
31
|
def aliyun_alias_url(style = default_style)
|
32
|
-
"
|
32
|
+
"#{oss_connection.aliyun_protocol}://#{oss_connection.aliyun_alias_host}/#{path(style).sub(%r{\A/}, '')}"
|
33
33
|
end
|
34
34
|
|
35
35
|
def exists?(style = default_style)
|
@@ -4,7 +4,7 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.require_path = 'lib'
|
5
5
|
s.summary = 'Extend a Aliyun OSS storage for paperclip'
|
6
6
|
s.description = 'Extend a Aliyun OSS storage for paperclip'
|
7
|
-
s.version = '0.1.
|
7
|
+
s.version = '0.1.2'
|
8
8
|
s.files = `git ls-files`.split("\n")
|
9
9
|
s.authors = ['Martin Hong', 'Aidi Stan']
|
10
10
|
s.email = 'hongzeqin@gmail.com'
|
data/spec/aliyun_spec.rb
CHANGED
@@ -70,7 +70,7 @@ describe Aliyun::Connection do
|
|
70
70
|
|
71
71
|
it "also return true for existed file with path include chinese characters" do
|
72
72
|
expect(@connection.exists?(@path_include_chinese)).to be_truthy
|
73
|
-
url = "
|
73
|
+
url = "#{@connection.aliyun_protocol}://#{@connection.aliyun_upload_host}/#{@path_include_chinese}"
|
74
74
|
expect(@connection.exists?(url)).to be_truthy
|
75
75
|
end
|
76
76
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip-storage-aliyun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Hong
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: paperclip
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
version: '0'
|
87
87
|
requirements: []
|
88
88
|
rubyforge_project:
|
89
|
-
rubygems_version: 2.
|
89
|
+
rubygems_version: 2.6.6
|
90
90
|
signing_key:
|
91
91
|
specification_version: 4
|
92
92
|
summary: Extend a Aliyun OSS storage for paperclip
|