fog-dtdream 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/fog-dtdream.gemspec +32 -0
- data/lib/fog/dtdream/core.rb +48 -0
- data/lib/fog/dtdream/models/storage/directories.rb +45 -0
- data/lib/fog/dtdream/models/storage/directory.rb +71 -0
- data/lib/fog/dtdream/models/storage/file.rb +174 -0
- data/lib/fog/dtdream/models/storage/files.rb +145 -0
- data/lib/fog/dtdream/requests/storage/copy_object.rb +32 -0
- data/lib/fog/dtdream/requests/storage/delete_bucket.rb +26 -0
- data/lib/fog/dtdream/requests/storage/delete_container.rb +32 -0
- data/lib/fog/dtdream/requests/storage/delete_object.rb +50 -0
- data/lib/fog/dtdream/requests/storage/get_bucket.rb +140 -0
- data/lib/fog/dtdream/requests/storage/get_container.rb +67 -0
- data/lib/fog/dtdream/requests/storage/get_containers.rb +72 -0
- data/lib/fog/dtdream/requests/storage/get_object.rb +42 -0
- data/lib/fog/dtdream/requests/storage/get_object_http_url.rb +39 -0
- data/lib/fog/dtdream/requests/storage/get_object_https_url.rb +97 -0
- data/lib/fog/dtdream/requests/storage/head_object.rb +31 -0
- data/lib/fog/dtdream/requests/storage/list_buckets.rb +46 -0
- data/lib/fog/dtdream/requests/storage/list_objects.rb +105 -0
- data/lib/fog/dtdream/requests/storage/put_bucket.rb +19 -0
- data/lib/fog/dtdream/requests/storage/put_container.rb +30 -0
- data/lib/fog/dtdream/requests/storage/put_object.rb +196 -0
- data/lib/fog/dtdream/storage.rb +206 -0
- data/lib/fog/dtdream/version.rb +5 -0
- data/lib/fog/dtdream.rb +9 -0
- metadata +108 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'xmlsimple'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Storage
|
5
|
+
class Dtdream
|
6
|
+
class Real
|
7
|
+
def list_objects(options={})
|
8
|
+
|
9
|
+
bucket = options[:bucket]
|
10
|
+
bucket ||= @aliyun_oss_bucket
|
11
|
+
prefix = options[:prefix]
|
12
|
+
marker = options[:marker]
|
13
|
+
maxKeys = options[:maxKeys]
|
14
|
+
delimiter = options[:delimiter]
|
15
|
+
|
16
|
+
path = ""
|
17
|
+
|
18
|
+
if prefix
|
19
|
+
path+="?prefix="+prefix
|
20
|
+
if marker
|
21
|
+
path+="&marker="+marker
|
22
|
+
end
|
23
|
+
if maxKeys
|
24
|
+
path+="&maxKeys="+maxKeys
|
25
|
+
end
|
26
|
+
if delimiter
|
27
|
+
path+="&delimiter="+delimiter
|
28
|
+
end
|
29
|
+
|
30
|
+
elsif marker
|
31
|
+
path+="?marker="+marker
|
32
|
+
if maxKeys
|
33
|
+
path+="&maxKeys="+maxKeys
|
34
|
+
end
|
35
|
+
if delimiter
|
36
|
+
path+="&delimiter="+delimiter
|
37
|
+
end
|
38
|
+
|
39
|
+
elsif maxKeys
|
40
|
+
path+="?maxKeys="+maxKeys
|
41
|
+
if delimiter
|
42
|
+
path+="&delimiter="+delimiter
|
43
|
+
end
|
44
|
+
elsif delimiter
|
45
|
+
path+="?delimiter="+delimiter
|
46
|
+
end
|
47
|
+
|
48
|
+
location = get_bucket_location(bucket)
|
49
|
+
endpoint = "http://"+location+".aliyuncs.com"
|
50
|
+
resource = bucket+'/'
|
51
|
+
ret = request(
|
52
|
+
:expects => [200, 203, 400],
|
53
|
+
:method => 'GET',
|
54
|
+
:path => path,
|
55
|
+
:resource => resource,
|
56
|
+
:bucket => bucket
|
57
|
+
)
|
58
|
+
xml = ret.data[:body]
|
59
|
+
result = XmlSimple.xml_in(xml)
|
60
|
+
end
|
61
|
+
|
62
|
+
def list_multipart_uploads(bucket, endpoint, options = {})
|
63
|
+
if (nil == endpoint)
|
64
|
+
location = get_bucket_location(bucket)
|
65
|
+
endpoint = "http://"+location+".aliyuncs.com"
|
66
|
+
end
|
67
|
+
path = "?uploads"
|
68
|
+
resource = bucket+'/'+path
|
69
|
+
|
70
|
+
ret = request(
|
71
|
+
:expects => 200,
|
72
|
+
:method => 'GET',
|
73
|
+
:path => path,
|
74
|
+
:bucket => bucket,
|
75
|
+
:resource => resource,
|
76
|
+
:endpoint => endpoint
|
77
|
+
)
|
78
|
+
uploadid = XmlSimple.xml_in(ret.data[:body])["Upload"]
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
def list_parts(bucket, object, endpoint, uploadid, options = {})
|
83
|
+
if (nil == endpoint)
|
84
|
+
location = get_bucket_location(bucket)
|
85
|
+
endpoint = "http://"+location+".aliyuncs.com"
|
86
|
+
end
|
87
|
+
path = object+"?uploadId="+uploadid
|
88
|
+
resource = bucket+'/'+path
|
89
|
+
|
90
|
+
ret = request(
|
91
|
+
:expects => 200,
|
92
|
+
:method => 'GET',
|
93
|
+
:path => path,
|
94
|
+
:bucket => bucket,
|
95
|
+
:resource => resource,
|
96
|
+
:endpoint => endpoint
|
97
|
+
)
|
98
|
+
parts = XmlSimple.xml_in(ret.data[:body])["Part"]
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class Dtdream
|
4
|
+
class Real
|
5
|
+
def put_bucket(bucketName)
|
6
|
+
|
7
|
+
resource = bucketName+'/'
|
8
|
+
ret = request(
|
9
|
+
:expects => [200, 203],
|
10
|
+
:method => 'PUT',
|
11
|
+
:resource => resource,
|
12
|
+
:bucket => bucketName
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class Dtdream
|
4
|
+
class Real
|
5
|
+
# Create a new container
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# * name<~String> - Name for container, ����·������β����Я��'/'
|
9
|
+
#
|
10
|
+
def put_container(name, options={})
|
11
|
+
bucket = options[:bucket]
|
12
|
+
bucket ||= @aliyun_oss_bucket
|
13
|
+
location = get_bucket_location(bucket)
|
14
|
+
endpoint = "http://"+location+".aliyuncs.com"
|
15
|
+
|
16
|
+
path = name+'/'
|
17
|
+
resource = bucket+'/'+name+'/'
|
18
|
+
request(
|
19
|
+
:expects => [200, 203],
|
20
|
+
:method => 'PUT',
|
21
|
+
:path => path,
|
22
|
+
:bucket => bucket,
|
23
|
+
:resource => resource,
|
24
|
+
:endpoint => endpoint
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class Dtdream
|
4
|
+
class Real
|
5
|
+
# Put details for object
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# * container<~String> - Name of container to look in
|
9
|
+
# * object<~String> - Name of object to look for
|
10
|
+
#
|
11
|
+
def put_object(object, file=nil, options={})
|
12
|
+
|
13
|
+
bucket = options[:bucket]
|
14
|
+
bucket ||= @aliyun_oss_bucket
|
15
|
+
location = get_bucket_location(bucket)
|
16
|
+
endpoint = "http://"+location+".aliyuncs.com"
|
17
|
+
if (nil == file)
|
18
|
+
return put_folder(bucket, object, endpoint)
|
19
|
+
end
|
20
|
+
|
21
|
+
#object size ����100M���߷�Ƭ�ϴ���֧�ֶϵ�����
|
22
|
+
if file.size >100 * 1024 * 1024
|
23
|
+
put_multipart_object(bucket, object, file)
|
24
|
+
return
|
25
|
+
end
|
26
|
+
|
27
|
+
body = file.read
|
28
|
+
|
29
|
+
resource = bucket+'/'+object
|
30
|
+
ret = request(
|
31
|
+
:expects => [200, 203],
|
32
|
+
:method => 'PUT',
|
33
|
+
:path => object,
|
34
|
+
:bucket => bucket,
|
35
|
+
:resource => resource,
|
36
|
+
:body => body,
|
37
|
+
:endpoint => endpoint
|
38
|
+
)
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
def put_object_with_body(object, body, options={})
|
43
|
+
|
44
|
+
bucket = options[:bucket]
|
45
|
+
bucket ||= @aliyun_oss_bucket
|
46
|
+
location = get_bucket_location(bucket)
|
47
|
+
endpoint = "http://"+location+".aliyuncs.com"
|
48
|
+
|
49
|
+
#object size ����100M���߷�Ƭ�ϴ���֧�ֶϵ�����
|
50
|
+
# if body.size >100 * 1024 * 1024
|
51
|
+
# put_multipart_object_with_body(bucket, object, body)
|
52
|
+
# return
|
53
|
+
# end
|
54
|
+
|
55
|
+
resource = bucket+'/'+object
|
56
|
+
ret = request(
|
57
|
+
:expects => [200, 203],
|
58
|
+
:method => 'PUT',
|
59
|
+
:path => object,
|
60
|
+
:bucket => bucket,
|
61
|
+
:resource => resource,
|
62
|
+
:body => body,
|
63
|
+
:endpoint => endpoint
|
64
|
+
)
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
def put_folder(bucket, folder, endpoint)
|
69
|
+
if (nil == endpoint)
|
70
|
+
location = get_bucket_location(bucket)
|
71
|
+
endpoint = "http://"+location+".aliyuncs.com"
|
72
|
+
end
|
73
|
+
path = folder+'/'
|
74
|
+
resource = bucket+'/'+folder+'/'
|
75
|
+
ret = request(
|
76
|
+
:expects => [200, 203],
|
77
|
+
:method => 'PUT',
|
78
|
+
:path => path,
|
79
|
+
:bucket => bucket,
|
80
|
+
:resource => resource,
|
81
|
+
:endpoint => endpoint
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
def put_multipart_object(bucket, object, file)
|
86
|
+
|
87
|
+
location = get_bucket_location(bucket)
|
88
|
+
endpoint = "http://"+location+".aliyuncs.com"
|
89
|
+
|
90
|
+
#����bucket��uploads�¼����ҵ���Ӧupload�������������upload�¼�
|
91
|
+
uploads = list_multipart_uploads(bucket, endpoint)
|
92
|
+
upload = uploads.find do |tmpupload| tmpupload["Key"][0] == object end
|
93
|
+
|
94
|
+
parts = nil
|
95
|
+
uploadedSize = 0
|
96
|
+
start_partNumber = 1
|
97
|
+
if ( nil != upload )
|
98
|
+
uploadId = upload["UploadId"][0]
|
99
|
+
parts = list_parts(bucket, object, endpoint, uploadId)
|
100
|
+
if ((nil != parts) &&(0 != parts.size))
|
101
|
+
if (parts[-1]["Size"][0].to_i != 5242880)
|
102
|
+
#�ϴ����һƬ����������5M,˵���Ѿ��ϴ���ϣ������ϴ�
|
103
|
+
complete_multipart_upload(bucket, object, endpoint, uploadId)
|
104
|
+
return
|
105
|
+
end
|
106
|
+
uploadedSize = (parts[0]["Size"][0].to_i * (parts.size - 1)) + parts[-1]["Size"][0].to_i
|
107
|
+
start_partNumber = parts[-1]["PartNumber"][0].to_i + 1
|
108
|
+
end
|
109
|
+
else
|
110
|
+
#InitiateMultipartUpload��ȡUpload ID
|
111
|
+
uploadId = initiate_multipart_upload(bucket, object, endpoint)
|
112
|
+
end
|
113
|
+
|
114
|
+
if (file.size <= uploadedSize)
|
115
|
+
#�ļ���СС�ڻ�������ϴ���,˵���Ѿ��ϴ���ϣ������ϴ�
|
116
|
+
complete_multipart_upload(bucket, object, endpoint, uploadId)
|
117
|
+
return
|
118
|
+
end
|
119
|
+
|
120
|
+
end_partNumber = (file.size + 5242880 -1) / 5242880
|
121
|
+
file.seek(uploadedSize)
|
122
|
+
|
123
|
+
for i in start_partNumber..end_partNumber
|
124
|
+
body = file.read(5242880)
|
125
|
+
upload_part(bucket, object, endpoint, i.to_s, uploadId, body)
|
126
|
+
end
|
127
|
+
|
128
|
+
complete_multipart_upload(bucket, object, endpoint, uploadId)
|
129
|
+
end
|
130
|
+
|
131
|
+
def initiate_multipart_upload(bucket, object, endpoint)
|
132
|
+
if (nil == endpoint)
|
133
|
+
location = get_bucket_location(bucket)
|
134
|
+
endpoint = "http://"+location+".aliyuncs.com"
|
135
|
+
end
|
136
|
+
path = object+"?uploads"
|
137
|
+
resource = bucket+'/'+path
|
138
|
+
ret = request(
|
139
|
+
:expects => 200,
|
140
|
+
:method => 'POST',
|
141
|
+
:path => path,
|
142
|
+
:bucket => bucket,
|
143
|
+
:resource => resource,
|
144
|
+
:endpoint => endpoint
|
145
|
+
)
|
146
|
+
uploadid = XmlSimple.xml_in(ret.data[:body])["UploadId"][0]
|
147
|
+
end
|
148
|
+
|
149
|
+
def upload_part(bucket, object, endpoint, partNumber, uploadId, body)
|
150
|
+
if (nil == endpoint)
|
151
|
+
location = get_bucket_location(bucket)
|
152
|
+
endpoint = "http://"+location+".aliyuncs.com"
|
153
|
+
end
|
154
|
+
path = object+"?partNumber="+partNumber+"&uploadId="+uploadId
|
155
|
+
resource = bucket+'/'+path
|
156
|
+
ret = request(
|
157
|
+
:expects => [200, 203],
|
158
|
+
:method => 'PUT',
|
159
|
+
:path => path,
|
160
|
+
:bucket => bucket,
|
161
|
+
:resource => resource,
|
162
|
+
:body => body,
|
163
|
+
:endpoint => endpoint
|
164
|
+
)
|
165
|
+
end
|
166
|
+
|
167
|
+
def complete_multipart_upload(bucket, object, endpoint, uploadId)
|
168
|
+
if (nil == endpoint)
|
169
|
+
location = get_bucket_location(bucket)
|
170
|
+
endpoint = "http://"+location+".aliyuncs.com"
|
171
|
+
end
|
172
|
+
parts = list_parts(bucket, object, endpoint, uploadId, options = {})
|
173
|
+
request_part = Array.new
|
174
|
+
for i in 0..(parts.size-1)
|
175
|
+
part = parts[i]
|
176
|
+
request_part[i] = {"PartNumber"=>part["PartNumber"], "ETag"=>part["ETag"]}
|
177
|
+
end
|
178
|
+
body =XmlSimple.xml_out({"Part"=>request_part},'RootName'=>'CompleteMultipartUpload')
|
179
|
+
|
180
|
+
path = object+"?uploadId="+uploadId
|
181
|
+
resource = bucket+'/'+path
|
182
|
+
ret = request(
|
183
|
+
:expects => 200,
|
184
|
+
:method => 'POST',
|
185
|
+
:path => path,
|
186
|
+
:bucket => bucket,
|
187
|
+
:resource => resource,
|
188
|
+
:endpoint => endpoint,
|
189
|
+
:body => body
|
190
|
+
)
|
191
|
+
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
@@ -0,0 +1,206 @@
|
|
1
|
+
require 'fog/dtdream/core'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Storage
|
5
|
+
class Dtdream < Fog::Service
|
6
|
+
recognizes :aliyun_oss_endpoint,
|
7
|
+
:aliyun_oss_location,
|
8
|
+
:aliyun_oss_bucket,
|
9
|
+
:aliyun_accesskey_id,
|
10
|
+
:aliyun_accesskey_secret
|
11
|
+
|
12
|
+
model_path 'fog/dtdream/models/storage'
|
13
|
+
model :directory
|
14
|
+
collection :directories
|
15
|
+
model :file
|
16
|
+
collection :files
|
17
|
+
|
18
|
+
request_path 'fog/dtdream/requests/storage'
|
19
|
+
request :copy_object
|
20
|
+
request :delete_bucket
|
21
|
+
request :delete_object
|
22
|
+
request :get_bucket
|
23
|
+
request :get_object
|
24
|
+
request :get_object_http_url
|
25
|
+
request :get_object_https_url
|
26
|
+
request :head_object
|
27
|
+
request :put_bucket
|
28
|
+
request :put_object
|
29
|
+
request :list_buckets
|
30
|
+
request :list_objects
|
31
|
+
request :get_containers
|
32
|
+
request :get_container
|
33
|
+
request :delete_container
|
34
|
+
request :put_container
|
35
|
+
|
36
|
+
class Real
|
37
|
+
attr_reader :aliyun_accesskey_id
|
38
|
+
attr_reader :aliyun_accesskey_secret
|
39
|
+
attr_reader :aliyun_oss_endpoint
|
40
|
+
attr_reader :aliyun_oss_location
|
41
|
+
attr_reader :aliyun_oss_bucket
|
42
|
+
|
43
|
+
def initialize(options={})
|
44
|
+
#��ʼ����λ�ȡ
|
45
|
+
@aliyun_oss_endpoint = options[:aliyun_oss_endpoint]
|
46
|
+
@aliyun_oss_location = options[:aliyun_oss_location]
|
47
|
+
@aliyun_accesskey_id = options[:aliyun_accesskey_id]
|
48
|
+
@aliyun_accesskey_secret = options[:aliyun_accesskey_secret]
|
49
|
+
@aliyun_oss_bucket = options[:aliyun_oss_bucket]
|
50
|
+
|
51
|
+
#��μ�飬�ؼ���������ȱ��
|
52
|
+
missing_credentials = Array.new
|
53
|
+
missing_credentials << :aliyun_oss_endpoint unless @aliyun_oss_endpoint
|
54
|
+
missing_credentials << :aliyun_oss_location unless @aliyun_oss_location
|
55
|
+
missing_credentials << :aliyun_accesskey_id unless @aliyun_accesskey_id
|
56
|
+
missing_credentials << :aliyun_accesskey_secret unless @aliyun_accesskey_secret
|
57
|
+
raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
|
58
|
+
|
59
|
+
@connection_options = options[:connection_options] || {}
|
60
|
+
|
61
|
+
uri = URI.parse(@aliyun_oss_endpoint)
|
62
|
+
@host = uri.host
|
63
|
+
@path = uri.path
|
64
|
+
@port = uri.port
|
65
|
+
@scheme = uri.scheme
|
66
|
+
|
67
|
+
@persistent = options[:persistent] || false
|
68
|
+
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
def reload
|
73
|
+
@connection.reset
|
74
|
+
end
|
75
|
+
|
76
|
+
def request(params)
|
77
|
+
method = params[:method]
|
78
|
+
time = Time.new.utc
|
79
|
+
date = time.strftime("%a, %d %b %Y %H:%M:%S GMT")
|
80
|
+
|
81
|
+
endpoint = params[:endpoint]
|
82
|
+
if endpoint
|
83
|
+
uri = URI.parse(endpoint)
|
84
|
+
host = uri.host
|
85
|
+
path = uri.path
|
86
|
+
port = uri.port
|
87
|
+
scheme = uri.scheme
|
88
|
+
else
|
89
|
+
host = @host
|
90
|
+
path = @path
|
91
|
+
port = @port
|
92
|
+
scheme = @scheme
|
93
|
+
end
|
94
|
+
|
95
|
+
bucket = params[:bucket]
|
96
|
+
if bucket
|
97
|
+
tmpHost = bucket + '.' + host
|
98
|
+
else
|
99
|
+
tmpHost = host
|
100
|
+
end
|
101
|
+
|
102
|
+
@connection = Fog::Core::Connection.new("#{scheme}://#{tmpHost}", @persistent, @connection_options)
|
103
|
+
contentType = params[:contentType]
|
104
|
+
|
105
|
+
begin
|
106
|
+
headers = ""
|
107
|
+
if params[:headers]
|
108
|
+
params[:headers].each do |k,v|
|
109
|
+
if k != "Range"
|
110
|
+
headers += "#{k}: #{v}\n"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
signature = sign(method, date, contentType, params[:resource], headers)
|
115
|
+
response = @connection.request(params.merge({
|
116
|
+
:headers => {
|
117
|
+
'Content-Type' => contentType,
|
118
|
+
'Authorization' =>'OSS '+@aliyun_accesskey_id+':'+signature,
|
119
|
+
'Date' => date
|
120
|
+
}.merge!(params[:headers] || {}),
|
121
|
+
:path => "#{path}/#{params[:path]}",
|
122
|
+
:query => params[:query]
|
123
|
+
}))
|
124
|
+
rescue Excon::Errors::HTTPStatusError => error
|
125
|
+
raise case error
|
126
|
+
when Excon::Errors::NotFound
|
127
|
+
Fog::Storage::Dtdream::NotFound.slurp(error)
|
128
|
+
else
|
129
|
+
error
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
response
|
134
|
+
end
|
135
|
+
|
136
|
+
#����signature
|
137
|
+
def sign (method, date, contentType, resource=nil, headers = nil)
|
138
|
+
contentmd5 = ""
|
139
|
+
|
140
|
+
if resource
|
141
|
+
canonicalizedResource = "/"+resource
|
142
|
+
else
|
143
|
+
canonicalizedResource = "/"
|
144
|
+
end
|
145
|
+
|
146
|
+
if headers
|
147
|
+
canonicalizedOSSHeaders = headers
|
148
|
+
else
|
149
|
+
canonicalizedOSSHeaders = ""
|
150
|
+
end
|
151
|
+
|
152
|
+
if contentType
|
153
|
+
contentTypeStr = contentType
|
154
|
+
else
|
155
|
+
contentTypeStr = ""
|
156
|
+
end
|
157
|
+
|
158
|
+
stringToSign = method+"\n"+contentmd5+"\n"+contentTypeStr+"\n"+date+"\n"+canonicalizedOSSHeaders+canonicalizedResource
|
159
|
+
|
160
|
+
digVer = OpenSSL::Digest.new("sha1")
|
161
|
+
digest = OpenSSL::HMAC.digest(digVer, @aliyun_accesskey_secret, stringToSign)
|
162
|
+
signature = Base64.encode64(digest)
|
163
|
+
signature[-1] = ""
|
164
|
+
|
165
|
+
return signature
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
class Mock
|
170
|
+
def self.data
|
171
|
+
@data ||= Hash.new do |hash, key|
|
172
|
+
hash[key] = {}
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def self.reset
|
177
|
+
@data = nil
|
178
|
+
end
|
179
|
+
|
180
|
+
def initialize(options={})
|
181
|
+
@openstack_api_key = options[:openstack_api_key]
|
182
|
+
@openstack_username = options[:openstack_username]
|
183
|
+
@path = '/v1/AUTH_1234'
|
184
|
+
end
|
185
|
+
|
186
|
+
def data
|
187
|
+
self.class.data[@openstack_username]
|
188
|
+
end
|
189
|
+
|
190
|
+
def reset_data
|
191
|
+
self.class.data.delete(@openstack_username)
|
192
|
+
end
|
193
|
+
|
194
|
+
def change_account(account)
|
195
|
+
@original_path ||= @path
|
196
|
+
version_string = @original_path.split('/')[1]
|
197
|
+
@path = "/#{version_string}/#{account}"
|
198
|
+
end
|
199
|
+
|
200
|
+
def reset_account_name
|
201
|
+
@path = @original_path
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
data/lib/fog/dtdream.rb
ADDED
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fog-dtdream
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- dengqinsi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: This library can be used as a module for `fog` or as standalone provider
|
42
|
+
to use the Aliyun Web Services in applications..
|
43
|
+
email:
|
44
|
+
- dengqs@dtdream.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- ".travis.yml"
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- bin/console
|
56
|
+
- bin/setup
|
57
|
+
- fog-dtdream.gemspec
|
58
|
+
- lib/fog/dtdream.rb
|
59
|
+
- lib/fog/dtdream/core.rb
|
60
|
+
- lib/fog/dtdream/models/storage/directories.rb
|
61
|
+
- lib/fog/dtdream/models/storage/directory.rb
|
62
|
+
- lib/fog/dtdream/models/storage/file.rb
|
63
|
+
- lib/fog/dtdream/models/storage/files.rb
|
64
|
+
- lib/fog/dtdream/requests/storage/copy_object.rb
|
65
|
+
- lib/fog/dtdream/requests/storage/delete_bucket.rb
|
66
|
+
- lib/fog/dtdream/requests/storage/delete_container.rb
|
67
|
+
- lib/fog/dtdream/requests/storage/delete_object.rb
|
68
|
+
- lib/fog/dtdream/requests/storage/get_bucket.rb
|
69
|
+
- lib/fog/dtdream/requests/storage/get_container.rb
|
70
|
+
- lib/fog/dtdream/requests/storage/get_containers.rb
|
71
|
+
- lib/fog/dtdream/requests/storage/get_object.rb
|
72
|
+
- lib/fog/dtdream/requests/storage/get_object_http_url.rb
|
73
|
+
- lib/fog/dtdream/requests/storage/get_object_https_url.rb
|
74
|
+
- lib/fog/dtdream/requests/storage/head_object.rb
|
75
|
+
- lib/fog/dtdream/requests/storage/list_buckets.rb
|
76
|
+
- lib/fog/dtdream/requests/storage/list_objects.rb
|
77
|
+
- lib/fog/dtdream/requests/storage/put_bucket.rb
|
78
|
+
- lib/fog/dtdream/requests/storage/put_container.rb
|
79
|
+
- lib/fog/dtdream/requests/storage/put_object.rb
|
80
|
+
- lib/fog/dtdream/storage.rb
|
81
|
+
- lib/fog/dtdream/version.rb
|
82
|
+
homepage: https://github.com/denques/fog-aliyun.git
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata:
|
86
|
+
allowed_push_host: https://rubygems.org
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.4.8
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Module for the 'fog' gem to support Aliyun Web Services.
|
107
|
+
test_files: []
|
108
|
+
has_rdoc:
|