qcloud-cos 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile.lock +1 -1
- data/lib/qcloud_cos/http.rb +4 -2
- data/lib/qcloud_cos/object_manager.rb +7 -6
- data/lib/qcloud_cos/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcd9ad3b80685b30e64389f95b633b707b5a5c43e389cb93d9ad3ca9a7e5de56
|
4
|
+
data.tar.gz: f2c7f6285c1fab0834903055324d786d823afd34f0da4760ca3c462198b73ee9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58661d7ff828784455d75ee51d7ef45fd64f654fa1dd3a6b423f2c206d99c0a438bd9eec9c0e9548f012f1c6211503e03a4d0b86d12558f41a413de479798c14
|
7
|
+
data.tar.gz: 38b103b8e3fe98857d0896dfa5a3826cb3c528f7495f4547bb4c42d2578187c4fe2a2bbb6d323eaf3e677bc2246c405574bb0dbfc1a92ed7b647c8be72259ea5
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/qcloud_cos/http.rb
CHANGED
@@ -5,11 +5,12 @@ require 'digest'
|
|
5
5
|
require 'net/http'
|
6
6
|
module QcloudCos
|
7
7
|
class Http
|
8
|
-
attr_accessor :access_id, :access_key
|
8
|
+
attr_accessor :access_id, :access_key, :token
|
9
9
|
|
10
|
-
def initialize(access_id, access_key)
|
10
|
+
def initialize(access_id, access_key, token: nil)
|
11
11
|
@access_id = access_id
|
12
12
|
@access_key = access_key
|
13
|
+
@token = token
|
13
14
|
end
|
14
15
|
|
15
16
|
def post(url, body = nil, headers = {})
|
@@ -30,6 +31,7 @@ module QcloudCos
|
|
30
31
|
|
31
32
|
def request(request_klass, url, body = nil, headers = {})
|
32
33
|
uri = URI.parse(url)
|
34
|
+
headers["x-cos-security-token"] = token if token
|
33
35
|
headers["Authorization"] = compute_auth(request_klass::METHOD, uri.request_uri, headers)
|
34
36
|
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |http|
|
35
37
|
request = request_klass.new(uri, headers)
|
@@ -1,18 +1,19 @@
|
|
1
1
|
require 'uri'
|
2
2
|
module QcloudCos
|
3
3
|
class ObjectManager
|
4
|
-
attr_accessor :bucket, :region, :access_id, :access_key, :
|
5
|
-
def initialize(bucket: nil, region: nil, access_id: nil, access_key: nil,
|
4
|
+
attr_accessor :bucket, :region, :access_id, :access_key, :http, :token
|
5
|
+
def initialize(bucket: nil, region: nil, access_id: nil, access_key: nil, token: nil)
|
6
6
|
@bucket = bucket
|
7
7
|
@region = region
|
8
8
|
@access_id = access_id
|
9
9
|
@access_key = access_key
|
10
|
-
@
|
11
|
-
@http = QcloudCos::Http.new(access_id, access_key)
|
10
|
+
@token = token
|
11
|
+
@http = QcloudCos::Http.new(access_id, access_key, token: token)
|
12
12
|
end
|
13
13
|
|
14
|
-
def put_object(path,
|
15
|
-
|
14
|
+
def put_object(path, file_or_bin, headers = {})
|
15
|
+
data = file_or_bin.respond_to?(:read) ? IO.binread(file_or_bin) : file_or_bin
|
16
|
+
http.put(compute_url(path), data, headers)
|
16
17
|
end
|
17
18
|
|
18
19
|
def copy_object(path, copy_source)
|
data/lib/qcloud_cos/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qcloud-cos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xuxiangyang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_xml
|