baidubce-sdk 0.9.1 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/baidubce-sdk.gemspec +5 -3
- data/lib/baidubce/bce_constants.rb +1 -0
- data/lib/baidubce/services/bos/bos_client.rb +37 -6
- data/lib/baidubce/version.rb +1 -1
- data/samples/baidubce/bos_sample.rb +2 -3
- metadata +23 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 54459c307d8f0e22399d42565dc66f5895deaa489cf88a51ee868aa6c27cb342
|
4
|
+
data.tar.gz: 52f14924396670c789493344807183f2255d2ccd1bdd17651b8d74e66334f96a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 014507f6ddf03fe3f0755a3648d81d5d91fb6e8a56d7e70cce8df332d33d0a402eb7215bf1aa01ea4b55e8f1675355ffcc54dabfbcfc36a6fef07c52b2b0c8ee
|
7
|
+
data.tar.gz: d5a179e2b931199b2f5f4b74d85a4cca4058db3c4049c6174382bd3dec07859df1d746b9fe3f9138d1e1a88a8952da94c5ea878cdca843237d833023e9ce7816
|
data/baidubce-sdk.gemspec
CHANGED
@@ -24,8 +24,10 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.15"
|
25
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
26
|
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
-
|
28
|
-
spec.
|
29
|
-
spec.
|
27
|
+
|
28
|
+
spec.add_runtime_dependency "rest-client", "~> 2.0", ">= 2.0.2"
|
29
|
+
spec.add_runtime_dependency "logger", "~> 1.2", ">= 1.2.8"
|
30
|
+
spec.add_runtime_dependency "mimemagic", "~> 0.3", ">= 0.3.2"
|
31
|
+
spec.add_runtime_dependency "unf_ext", "0.0.7.7"
|
30
32
|
spec.required_ruby_version = ">= 2.0.0"
|
31
33
|
end
|
@@ -21,11 +21,10 @@ module Baidubce
|
|
21
21
|
module Services
|
22
22
|
|
23
23
|
class BosClient < BceBaseClient
|
24
|
-
|
25
24
|
# List buckets of user.
|
26
25
|
# returns all buckets owned by the user.
|
27
26
|
def list_buckets()
|
28
|
-
send_request(GET)
|
27
|
+
send_request(GET, "", {}, "", {}, "", nil, false, true)
|
29
28
|
end
|
30
29
|
|
31
30
|
# Create bucket with specific name.
|
@@ -248,7 +247,7 @@ module Baidubce
|
|
248
247
|
def generate_pre_signed_url(bucket_name, key, options={})
|
249
248
|
headers = options['headers'].nil? ? {} : options['headers']
|
250
249
|
params = options['params'].nil? ? {} : options['params']
|
251
|
-
|
250
|
+
gen_host(bucket_name, false)
|
252
251
|
path = Utils.append_uri("/", key)
|
253
252
|
url, headers[HOST] = Utils.parse_url_host(@config)
|
254
253
|
unless @config.cname_enabled || Utils.is_cname_like_host(@config.endpoint)
|
@@ -422,13 +421,45 @@ module Baidubce
|
|
422
421
|
send_request(DELETE, bucket_name, params, key)
|
423
422
|
end
|
424
423
|
|
425
|
-
def
|
424
|
+
def gen_host(bucket_name, is_bucket_api)
|
425
|
+
endpoint = @config.endpoint
|
426
|
+
unless endpoint.include?"://"
|
427
|
+
protocol = @config.protocol.downcase
|
428
|
+
raise "Invalid protocol #{protocol}." if protocol != "http" && protocol != 'https'
|
429
|
+
endpoint = sprintf("%s://%s", protocol, endpoint)
|
430
|
+
end
|
431
|
+
parsed_endpoint = URI.parse(endpoint)
|
432
|
+
scheme = parsed_endpoint.scheme.downcase
|
433
|
+
host = parsed_endpoint.host
|
434
|
+
parts = host.split('.')
|
435
|
+
if is_bucket_api == true
|
436
|
+
@config.cname_enabled = false
|
437
|
+
if host.include?(DEFAULT_BOS_DOMAIN)
|
438
|
+
last_three_elements = parts.last(3)
|
439
|
+
host = last_three_elements.join('.')
|
440
|
+
end
|
441
|
+
else
|
442
|
+
if @config.cname_enabled == false
|
443
|
+
@config.cname_enabled = true
|
444
|
+
if parts.length == 3
|
445
|
+
host = [bucket_name, parts[0], parts[1], parts[2]].join('.')
|
446
|
+
end
|
447
|
+
end
|
448
|
+
end
|
449
|
+
port = parsed_endpoint.port
|
450
|
+
host += ":#{port}" unless scheme == 'http' && port == 80 || scheme == 'https' && port == 443
|
451
|
+
@config.endpoint = host
|
452
|
+
end
|
453
|
+
|
454
|
+
def send_request(http_method, bucket_name="", params={}, key="", headers={}, body="", save_path=nil, return_body=false, is_bucket_api=false, &block)
|
455
|
+
gen_host(bucket_name, is_bucket_api)
|
426
456
|
if @config.cname_enabled || Utils.is_cname_like_host(@config.endpoint)
|
427
457
|
path = Utils.append_uri("/", key)
|
428
458
|
else
|
429
|
-
|
459
|
+
if is_bucket_api == false
|
460
|
+
path = Utils.append_uri("/", bucket_name, key)
|
461
|
+
end
|
430
462
|
end
|
431
|
-
|
432
463
|
begin
|
433
464
|
resp_body, resp_headers = @http_client.send_request(@config, @signer, http_method, path, params,
|
434
465
|
headers, body, save_path, false, &block)
|
data/lib/baidubce/version.rb
CHANGED
@@ -19,8 +19,8 @@ include Baidubce
|
|
19
19
|
|
20
20
|
# debug
|
21
21
|
credentials = Auth::BceCredentials.new(
|
22
|
-
|
23
|
-
|
22
|
+
# "your ak",
|
23
|
+
# "your sk"
|
24
24
|
)
|
25
25
|
|
26
26
|
conf = BceClientConfiguration.new(
|
@@ -176,7 +176,6 @@ demo "put object" do
|
|
176
176
|
'Content-Disposition' => 'inline',
|
177
177
|
'user-metadata' => user_metadata
|
178
178
|
}
|
179
|
-
|
180
179
|
client.put_object_from_string(bucket_name, "obj.txt", "obj", options)
|
181
180
|
puts client.get_object_as_string(bucket_name, "obj.txt")
|
182
181
|
puts client.get_object_to_file(bucket_name, "obj.txt", "obj_file.txt")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baidubce-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xiaoyong
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: lib/baidubce
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -62,7 +62,7 @@ dependencies:
|
|
62
62
|
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: 2.0.2
|
65
|
-
type: :
|
65
|
+
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
- - ">="
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: 1.2.8
|
85
|
-
type: :
|
85
|
+
type: :runtime
|
86
86
|
prerelease: false
|
87
87
|
version_requirements: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
@@ -102,7 +102,7 @@ dependencies:
|
|
102
102
|
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: 0.3.2
|
105
|
-
type: :
|
105
|
+
type: :runtime
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
@@ -112,6 +112,20 @@ dependencies:
|
|
112
112
|
- - ">="
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: 0.3.2
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: unf_ext
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - '='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: 0.0.7.7
|
122
|
+
type: :runtime
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - '='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 0.0.7.7
|
115
129
|
description: The official Ruby sdk used to accessing BaiduBce Object Storage Service
|
116
130
|
email:
|
117
131
|
- xiaoyong@baidu.com
|
@@ -149,7 +163,7 @@ homepage: https://github.com/baidubce/bce-sdk-ruby
|
|
149
163
|
licenses:
|
150
164
|
- Apache-2.0
|
151
165
|
metadata: {}
|
152
|
-
post_install_message:
|
166
|
+
post_install_message:
|
153
167
|
rdoc_options: []
|
154
168
|
require_paths:
|
155
169
|
- lib
|
@@ -164,9 +178,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
178
|
- !ruby/object:Gem::Version
|
165
179
|
version: '0'
|
166
180
|
requirements: []
|
167
|
-
|
168
|
-
|
169
|
-
signing_key:
|
181
|
+
rubygems_version: 3.5.4
|
182
|
+
signing_key:
|
170
183
|
specification_version: 4
|
171
184
|
summary: BaiduBce BOS Ruby SDK
|
172
185
|
test_files: []
|