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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 031e03e9ed5b011e41422461d2b8a40c6d1365751f7eff03a51a732fc3714a25
4
- data.tar.gz: facfc40f4432c5d0b77a1b988a5ab04bc1ef760523a282733188a228e9156b31
3
+ metadata.gz: fcd9ad3b80685b30e64389f95b633b707b5a5c43e389cb93d9ad3ca9a7e5de56
4
+ data.tar.gz: f2c7f6285c1fab0834903055324d786d823afd34f0da4760ca3c462198b73ee9
5
5
  SHA512:
6
- metadata.gz: d7033bc2f3c3fba54d5d60875c8442059e7dea626b4df46000d0646f6a0d6df85785bc01b29008bd4f14f897bbb0668df2d21c060479911d93167b2bb2093ef6
7
- data.tar.gz: df46f0b7aed195986bf2a6419735df6b2f772224b74576d8a7a5d7407484c8668a38a1e00b8b7d043d9115569c001933ac3ef8356216176816bf378b587ecd4b
6
+ metadata.gz: 58661d7ff828784455d75ee51d7ef45fd64f654fa1dd3a6b423f2c206d99c0a438bd9eec9c0e9548f012f1c6211503e03a4d0b86d12558f41a413de479798c14
7
+ data.tar.gz: 38b103b8e3fe98857d0896dfa5a3826cb3c528f7495f4547bb4c42d2578187c4fe2a2bbb6d323eaf3e677bc2246c405574bb0dbfc1a92ed7b647c8be72259ea5
@@ -4,4 +4,8 @@
4
4
 
5
5
  ### 新增
6
6
  * 上传Object
7
- * 复制Object
7
+ * 复制Object
8
+
9
+ ## 0.0.4
10
+ * ObjectManager的put_object支持file或bin_data
11
+ * ObjectManager增加了临时token支持
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qcloud-cos (0.0.3)
4
+ qcloud-cos (0.0.4)
5
5
  activesupport
6
6
  multi_xml
7
7
 
@@ -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, :app_id, :http
5
- def initialize(bucket: nil, region: nil, access_id: nil, access_key: nil, app_id: 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
- @app_id = app_id
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, file, headers = {})
15
- http.put(compute_url(path), file.read, headers)
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)
@@ -1,3 +1,3 @@
1
1
  module QcloudCos
2
- VERSION = "0.0.3".freeze
2
+ VERSION = "0.0.4".freeze
3
3
  end
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.3
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-25 00:00:00.000000000 Z
11
+ date: 2019-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_xml