tencent_cos_sdk 0.1.2 → 0.2.0
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/lib/tencent_cos_sdk/request.rb +8 -9
- data/lib/tencent_cos_sdk/utils.rb +11 -1
- data/lib/tencent_cos_sdk/version.rb +1 -1
- data/lib/tencent_cos_sdk.rb +3 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c05cabab083444a58f54d2c23e20ad1a77a5889
|
4
|
+
data.tar.gz: cf903de3f333951eba8d7cc29737b5dd05544e33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab87e308ff8fc5907558384ad7c8eeb919a5e14098f78f81c707fcba53108d404e3970a6eafc6b2e07fa02416384e9f6ad0ec6f93d386d44ef9cf8e4c65d0ae0
|
7
|
+
data.tar.gz: df7cf33752d4cf4058fc517ed93ede94f63a2d6765b8a936bfd98297f44788d096e5f47baab8df34cde67ee946d9f07ce4d9f6c329e1d0e5ed7233a4363e7a18
|
@@ -4,12 +4,12 @@ require 'tencent_cos_sdk/utils'
|
|
4
4
|
|
5
5
|
module TencentCosSdk
|
6
6
|
class Request
|
7
|
-
attr_accessor :http_method, :
|
7
|
+
attr_accessor :http_method, :path, :headers, :body, :file
|
8
8
|
attr_accessor :response, :time_used
|
9
9
|
|
10
10
|
def initialize options
|
11
11
|
self.http_method = options[:http_method]
|
12
|
-
self.
|
12
|
+
self.path = options[:path]
|
13
13
|
self.headers = options[:headers] || {}
|
14
14
|
self.body = options[:body]
|
15
15
|
self.file = options[:file]
|
@@ -26,7 +26,7 @@ module TencentCosSdk
|
|
26
26
|
|
27
27
|
options = {
|
28
28
|
method: http_method,
|
29
|
-
url:
|
29
|
+
url: TencentCosSdk.url(path),
|
30
30
|
headers: headers,
|
31
31
|
verify_ssl: false
|
32
32
|
}
|
@@ -47,11 +47,10 @@ module TencentCosSdk
|
|
47
47
|
puts response_description
|
48
48
|
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
IO.binwrite(file_path, response) if m
|
50
|
+
if /attachment; filename\*="UTF-8''(.+)"/.match response.headers[:content_disposition]
|
51
|
+
FileUtils.mkdir_p File.dirname(path)
|
52
|
+
IO.binwrite(path, response)
|
53
|
+
end
|
55
54
|
|
56
55
|
response
|
57
56
|
end
|
@@ -60,7 +59,7 @@ module TencentCosSdk
|
|
60
59
|
|
61
60
|
def description
|
62
61
|
s = "\n\n"
|
63
|
-
s << "#{http_method.upcase} #{uri} HTTP/1.1\n".light_magenta
|
62
|
+
s << "#{http_method.upcase} #{TencentCosSdk.uri(@path)} HTTP/1.1\n".light_magenta
|
64
63
|
|
65
64
|
headers.each do |k, v|
|
66
65
|
s << "#{k}: #{v}\n".red
|
@@ -2,6 +2,16 @@ require 'cgi'
|
|
2
2
|
require 'openssl'
|
3
3
|
|
4
4
|
module TencentCosSdk
|
5
|
+
class << self
|
6
|
+
def uri(path)
|
7
|
+
"#{TencentCosSdk.conf.parent_path.to_s}/#{path}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def url(path)
|
11
|
+
"https://#{TencentCosSdk.conf.host}#{uri path}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
5
15
|
class Request
|
6
16
|
def get_authorization
|
7
17
|
sign_time = "#{Time.now.to_i - 3600};#{Time.now.to_i + 3600}"
|
@@ -26,7 +36,7 @@ module TencentCosSdk
|
|
26
36
|
|
27
37
|
def get_http_string
|
28
38
|
http_string = http_method + "\n"
|
29
|
-
http_string += uri + "\n"
|
39
|
+
http_string += TencentCosSdk.uri(@path) + "\n"
|
30
40
|
http_string += get_params + "\n"
|
31
41
|
http_string += get_headers + "\n"
|
32
42
|
end
|
data/lib/tencent_cos_sdk.rb
CHANGED
@@ -9,27 +9,21 @@ module TencentCosSdk
|
|
9
9
|
# TencentCosSdk.put '1/abc.txt', file: './xyz.txt'
|
10
10
|
#
|
11
11
|
def put path, options = {}
|
12
|
-
Request.new(options.merge http_method: 'put',
|
12
|
+
Request.new(options.merge http_method: 'put', path: path, sign: true).execute
|
13
13
|
end
|
14
14
|
|
15
15
|
#
|
16
16
|
# TencentCosSdk.get '1/abc.txt'
|
17
17
|
#
|
18
18
|
def get path, options = {}
|
19
|
-
Request.new(options.merge http_method: 'get',
|
19
|
+
Request.new(options.merge http_method: 'get', path: path).execute
|
20
20
|
end
|
21
21
|
|
22
22
|
#
|
23
23
|
# TencentCosSdk.delete '1/abc.txt'
|
24
24
|
#
|
25
25
|
def delete path, options = {}
|
26
|
-
Request.new(options.merge http_method: 'delete',
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def uri path
|
32
|
-
File.join TencentCosSdk.conf.parent_path, path
|
26
|
+
Request.new(options.merge http_method: 'delete', path: path, sign: true).execute
|
33
27
|
end
|
34
28
|
end
|
35
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tencent_cos_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xia xiongjun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: openssl
|