fog-xiaozhu 0.2.1 → 0.2.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 -8
- data/lib/fog/aliyun/storage.rb +14 -38
- data/lib/fog/aliyun/version.rb +1 -1
- 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: c1ed05f3f7da66e49b666241541244cc978362fc
|
4
|
+
data.tar.gz: 9982ae5765a7eed4a8d32177c85c46d538339578
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f651be8538f6075bd546c6fe4511112aab5c4e080f243cc3fa87c46a703a2efb73701f59eb7e47e7630f5780c52af47c0f1e6220a6db0bf23a55bfe2a6f33b0
|
7
|
+
data.tar.gz: be45df163589e9742425b99240600cf9112757e629c18baed72103a25324ad59708934eff9fa85e63998d2b5e32909022d28cca4123fdd784de029e8ded478ac
|
data/README.md
CHANGED
@@ -32,7 +32,9 @@ Since it's a bad practice to have your credentials in source code, you should lo
|
|
32
32
|
default:
|
33
33
|
:aliyun_accesskey_id: <YOUR_ACCESS_KEY_ID>,
|
34
34
|
:aliyun_accesskey_secret: <YOUR_SECRET_ACCESS_KEY>,
|
35
|
-
:
|
35
|
+
:aliyun_oss_endpoint: <YOUR_OSS_ENDPOINT>,
|
36
|
+
:aliyun_oss_location: <YOUR_OSS_LOACTION>,
|
37
|
+
:aliyun_oss_bucket: <YOUR_OSS_BUCKET>
|
36
38
|
```
|
37
39
|
|
38
40
|
### Connecting to OSS
|
@@ -46,17 +48,12 @@ opt = {
|
|
46
48
|
:provider => 'aliyun',
|
47
49
|
:aliyun_accesskey_id => <YOUR_ACCESS_KEY_ID>,
|
48
50
|
:aliyun_accesskey_secret => <YOUR_SECRET_ACCESS_KEY>,
|
49
|
-
:aliyun_oss_bucket => <YOUR_OSS_BUCKET>,
|
50
|
-
:aliyun_region_id => <YOUR_TARGET_REGION>,
|
51
51
|
:aliyun_oss_endpoint => <YOUR_OSS_ENDPOINT>,
|
52
|
+
:aliyun_oss_location => <YOUR_OSS_LOACTION>,
|
53
|
+
:aliyun_oss_bucket => <YOUR_OSS_BUCKET>,
|
52
54
|
}
|
53
55
|
conn = Fog::Storage.new(opt)
|
54
56
|
```
|
55
|
-
**-> Note:** `:aliyun_region_id` is optional and default to "cn-hangzhou".
|
56
|
-
**-> Note:** `:aliyun_oss_endpoint` is optional. If it is not specified, it will be generated automatically by `:aliyun_region_id`.
|
57
|
-
Its basic format is "oss-<region-id>.aliyuncs.com" and with default schema "http" and default port "80".
|
58
|
-
If you want to use https or 443 port, you can use a format "<schema>://oss-<region-id>.aliyuncs.com:<port>".
|
59
|
-
|
60
57
|
|
61
58
|
## Fog::Aliyun Abstractions
|
62
59
|
|
data/lib/fog/aliyun/storage.rb
CHANGED
@@ -3,21 +3,11 @@ require 'xmlsimple'
|
|
3
3
|
module Fog
|
4
4
|
module Storage
|
5
5
|
class Aliyun < Fog::Service
|
6
|
-
|
7
|
-
DEFAULT_REGION = 'cn-hangzhou'
|
8
|
-
|
9
|
-
DEFAULT_SCHEME = 'http'
|
10
|
-
DEFAULT_SCHEME_PORT = {
|
11
|
-
'http' => 80,
|
12
|
-
'https' => 443
|
13
|
-
}
|
14
|
-
|
15
6
|
recognizes :aliyun_oss_endpoint,
|
16
7
|
:aliyun_oss_location,
|
17
|
-
:aliyun_region_id
|
18
|
-
requires :aliyun_accesskey_id,
|
19
|
-
:aliyun_accesskey_secret,
|
20
8
|
:aliyun_oss_bucket
|
9
|
+
requires :aliyun_accesskey_id,
|
10
|
+
:aliyun_accesskey_secret
|
21
11
|
|
22
12
|
model_path 'fog/aliyun/models/storage'
|
23
13
|
model :directory
|
@@ -47,9 +37,9 @@ module Fog
|
|
47
37
|
# Initialize connection to OSS
|
48
38
|
#
|
49
39
|
# ==== Notes
|
50
|
-
# options parameter must include values for :
|
51
|
-
# :aliyun_oss_location
|
52
|
-
# if
|
40
|
+
# options parameter must include values for :aliyun_oss_endpoint, :aliyun_accesskey_id,
|
41
|
+
# :aliyun_secret_access_key, :aliyun_oss_location and :aliyun_oss_bucket in order to create a connection.
|
42
|
+
# if you haven't set these values in the configuration file.
|
53
43
|
#
|
54
44
|
# ==== Examples
|
55
45
|
# sdb = Fog::Storage.new(:provider=>'aliyun',
|
@@ -65,37 +55,32 @@ module Fog
|
|
65
55
|
attr_reader :aliyun_accesskey_id
|
66
56
|
attr_reader :aliyun_accesskey_secret
|
67
57
|
attr_reader :aliyun_oss_endpoint
|
68
|
-
attr_reader :
|
58
|
+
attr_reader :aliyun_oss_location
|
69
59
|
attr_reader :aliyun_oss_bucket
|
70
60
|
|
71
61
|
def initialize(options = {})
|
72
62
|
# initialize the parameters
|
73
|
-
@
|
74
|
-
@
|
63
|
+
@aliyun_oss_endpoint = options[:aliyun_oss_endpoint]
|
64
|
+
@aliyun_oss_location = options[:aliyun_oss_location]
|
75
65
|
@aliyun_accesskey_id = options[:aliyun_accesskey_id]
|
76
66
|
@aliyun_accesskey_secret = options[:aliyun_accesskey_secret]
|
77
67
|
@aliyun_oss_bucket = options[:aliyun_oss_bucket]
|
78
68
|
|
79
69
|
# check for the parameters
|
80
70
|
missing_credentials = []
|
81
|
-
missing_credentials << :
|
71
|
+
missing_credentials << :aliyun_oss_endpoint unless @aliyun_oss_endpoint
|
72
|
+
missing_credentials << :aliyun_oss_location unless @aliyun_oss_location
|
82
73
|
missing_credentials << :aliyun_accesskey_id unless @aliyun_accesskey_id
|
83
74
|
missing_credentials << :aliyun_accesskey_secret unless @aliyun_accesskey_secret
|
84
75
|
raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
|
85
76
|
|
86
77
|
@connection_options = options[:connection_options] || {}
|
87
78
|
|
88
|
-
endpoint = @aliyun_oss_endpoint
|
89
|
-
|
90
|
-
if !endpoint.start_with?(DEFAULT_SCHEME)
|
91
|
-
@aliyun_oss_endpoint = "#{DEFAULT_SCHEME}://#{endpoint}"
|
92
|
-
end
|
93
|
-
|
94
79
|
uri = URI.parse(@aliyun_oss_endpoint)
|
95
80
|
@host = uri.host
|
96
81
|
@path = uri.path
|
97
|
-
@
|
98
|
-
@
|
82
|
+
@port = uri.port
|
83
|
+
@scheme = uri.scheme
|
99
84
|
|
100
85
|
@persistent = options[:persistent] || false
|
101
86
|
end
|
@@ -104,15 +89,6 @@ module Fog
|
|
104
89
|
@connection.reset
|
105
90
|
end
|
106
91
|
|
107
|
-
def region_to_endpoint(region=nil)
|
108
|
-
case region.to_s
|
109
|
-
when ''
|
110
|
-
"oss-#{DEFAULT_REGION}.aliyuncs.com"
|
111
|
-
else
|
112
|
-
"oss-#{region}.aliyuncs.com"
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
92
|
def request(params)
|
117
93
|
method = params[:method]
|
118
94
|
time = Time.new.utc
|
@@ -205,14 +181,14 @@ module Fog
|
|
205
181
|
class Mock
|
206
182
|
def initialize(options = {})
|
207
183
|
@aliyun_oss_endpoint = options[:aliyun_oss_endpoint]
|
208
|
-
@
|
184
|
+
@aliyun_oss_location = options[:aliyun_oss_location]
|
209
185
|
@aliyun_accesskey_id = options[:aliyun_accesskey_id]
|
210
186
|
@aliyun_accesskey_secret = options[:aliyun_accesskey_secret]
|
211
187
|
@aliyun_oss_bucket = options[:aliyun_oss_bucket]
|
212
188
|
|
213
189
|
# missing_credentials = Array.new
|
214
190
|
# missing_credentials << :aliyun_oss_endpoint unless @aliyun_oss_endpoint
|
215
|
-
# missing_credentials << :
|
191
|
+
# missing_credentials << :aliyun_oss_location unless @aliyun_oss_location
|
216
192
|
# missing_credentials << :aliyun_accesskey_id unless @aliyun_accesskey_id
|
217
193
|
# missing_credentials << :aliyun_accesskey_secret unless @aliyun_accesskey_secret
|
218
194
|
# raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
|
data/lib/fog/aliyun/version.rb
CHANGED