paperclip-storage-aliyun 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aliyun/connection.rb +5 -1
- data/lib/aliyun/data_center.rb +3 -1
- data/lib/paperclip/storage/aliyun.rb +12 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff16e09b8b10e23dd324564800cc616a8a18f10f8b565232cc07828f188e4187
|
4
|
+
data.tar.gz: b19db842235f98300bebe578bc0ba04fe5d3901382aea376b14b5ecf49e7eae3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b25f22a60b2c143cb8defa97c95046f7b03520298ba9a9467bd9252ff7629025aa7e3201cf4be8c38b093ea5e3730dc1d35d49eaa93e003953c82ff5b40f6e3f
|
7
|
+
data.tar.gz: dc7a329077c64cde95e3ffa7389f18bb386e1cd3d058434301e5e1e9db5ea6b122470b593f10bfc97f885b97e319fa7e83f07387cf752e56ea5ef4932f5baa25
|
data/lib/aliyun/connection.rb
CHANGED
@@ -20,6 +20,8 @@ module Aliyun
|
|
20
20
|
|
21
21
|
attr_reader :aliyun_protocol
|
22
22
|
|
23
|
+
attr_reader :aliyun_protocol_relative_url
|
24
|
+
|
23
25
|
# Initialize the OSS connection
|
24
26
|
#
|
25
27
|
# @param [Hash] An options to specify connection details
|
@@ -29,15 +31,17 @@ module Aliyun
|
|
29
31
|
# @option data_center [String] available data center name, e.g. 'cn-hangzhou'
|
30
32
|
# @option internal [true, false] if the service should be accessed through internal network
|
31
33
|
# @option host_alias [String] the alias of the host, such as the CDN domain name
|
34
|
+
# @option protocol [String] 'http' or 'https', default to 'http'
|
35
|
+
# @option protocol_relative_url [true, false] if to use protocol relative url, https://en.wikipedia.org/wiki/Wikipedia:Protocol-relative_URL
|
32
36
|
# @note both access_id and acces_key are related to authorization algorithm:
|
33
37
|
# https://docs.aliyun.com/#/pub/oss/api-reference/access-control&signature-header
|
34
38
|
def initialize(options = {})
|
35
39
|
@aliyun_access_id = options[:access_id]
|
36
40
|
@aliyun_access_key = options[:access_key]
|
37
41
|
@aliyun_bucket = options[:bucket]
|
42
|
+
@aliyun_protocol_relative_url = !!options[:protocol_relative_url]
|
38
43
|
@aliyun_protocol = options[:protocol] || 'http'
|
39
44
|
|
40
|
-
|
41
45
|
@aliyun_upload_host = "#{@aliyun_bucket}.#{get_endpoint(options)}"
|
42
46
|
@aliyun_internal_host = "#{@aliyun_bucket}.#{get_endpoint(options.merge(internal: true))}"
|
43
47
|
@aliyun_external_host = "#{@aliyun_bucket}.#{get_endpoint(options.merge(internal: false))}"
|
data/lib/aliyun/data_center.rb
CHANGED
@@ -2,7 +2,7 @@ require 'aliyun/errors'
|
|
2
2
|
|
3
3
|
module Aliyun
|
4
4
|
module DataCenter
|
5
|
-
# https://
|
5
|
+
# https://help.aliyun.com/document_detail/31837.html
|
6
6
|
AVAILABLE_DATA_CENTERS = %w(
|
7
7
|
oss-cn-hangzhou
|
8
8
|
oss-cn-shanghai
|
@@ -11,6 +11,8 @@ module Aliyun
|
|
11
11
|
oss-cn-zhangjiakou
|
12
12
|
oss-cn-huhehaote
|
13
13
|
oss-cn-shenzhen
|
14
|
+
oss-cn-heyuan
|
15
|
+
oss-cn-chengdu
|
14
16
|
oss-cn-hongkong
|
15
17
|
oss-us-west-1
|
16
18
|
oss-us-east-1
|
@@ -16,20 +16,28 @@ module Paperclip
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def build_aliyun_object_url(host, style)
|
20
|
+
if oss_connection.aliyun_protocol_relative_url
|
21
|
+
"//#{host}/#{path(style).sub(%r{\A/}, '')}"
|
22
|
+
else
|
23
|
+
"#{oss_connection.aliyun_protocol}://#{host}/#{path(style).sub(%r{\A/}, '')}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
19
27
|
def aliyun_upload_url(style = default_style)
|
20
|
-
|
28
|
+
build_aliyun_object_url(oss_connection.aliyun_upload_host, style)
|
21
29
|
end
|
22
30
|
|
23
31
|
def aliyun_internal_url(style = default_style)
|
24
|
-
|
32
|
+
build_aliyun_object_url(oss_connection.aliyun_internal_host, style)
|
25
33
|
end
|
26
34
|
|
27
35
|
def aliyun_external_url(style = default_style)
|
28
|
-
|
36
|
+
build_aliyun_object_url(oss_connection.aliyun_external_host, style)
|
29
37
|
end
|
30
38
|
|
31
39
|
def aliyun_alias_url(style = default_style)
|
32
|
-
|
40
|
+
build_aliyun_object_url(oss_connection.aliyun_alias_host, style)
|
33
41
|
end
|
34
42
|
|
35
43
|
def exists?(style = default_style)
|
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.5
|
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: 2020-06-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: paperclip
|
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
|
-
rubygems_version: 3.0.
|
72
|
+
rubygems_version: 3.0.6
|
73
73
|
signing_key:
|
74
74
|
specification_version: 4
|
75
75
|
summary: Extend a Aliyun OSS storage for paperclip
|