aliyun-sdk 0.1.3 → 0.1.4
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/CHANGELOG.md +21 -0
- data/examples/aliyun/oss/bucket.rb +144 -0
- data/examples/aliyun/oss/object.rb +182 -0
- data/examples/aliyun/oss/resumable_download.rb +40 -0
- data/examples/aliyun/oss/resumable_upload.rb +46 -0
- data/examples/aliyun/oss/streaming.rb +124 -0
- data/lib/aliyun/oss/bucket.rb +78 -23
- data/lib/aliyun/oss/client.rb +2 -0
- data/lib/aliyun/oss/download.rb +62 -27
- data/lib/aliyun/oss/http.rb +6 -2
- data/lib/aliyun/oss/iterator.rb +18 -0
- data/lib/aliyun/oss/logging.rb +5 -2
- data/lib/aliyun/oss/multipart.rb +3 -2
- data/lib/aliyun/oss/object.rb +1 -1
- data/lib/aliyun/oss/protocol.rb +17 -21
- data/lib/aliyun/oss/upload.rb +58 -19
- data/lib/aliyun/oss/util.rb +1 -0
- data/lib/aliyun/oss/version.rb +1 -1
- data/spec/aliyun/oss/client/bucket_spec.rb +88 -2
- data/spec/aliyun/oss/client/resumable_download_spec.rb +8 -5
- data/spec/aliyun/oss/client/resumable_upload_spec.rb +7 -4
- data/spec/aliyun/oss/multipart_spec.rb +0 -10
- data/spec/aliyun/oss/object_spec.rb +9 -10
- data/tests/test_content_type.rb +100 -0
- data/tests/test_large_file.rb +66 -0
- data/tests/test_multipart.rb +105 -0
- data/tests/test_object_key.rb +71 -0
- data/tests/test_resumable.rb +41 -0
- metadata +19 -2
@@ -0,0 +1,71 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'yaml'
|
4
|
+
$LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__))
|
5
|
+
require 'aliyun/oss'
|
6
|
+
|
7
|
+
class TestObjectKey < Minitest::Test
|
8
|
+
def setup
|
9
|
+
Aliyun::OSS::Logging.set_log_level(Logger::DEBUG)
|
10
|
+
conf_file = '~/.oss.yml'
|
11
|
+
conf = YAML.load(File.read(File.expand_path(conf_file)))
|
12
|
+
client = Aliyun::OSS::Client.new(
|
13
|
+
:endpoint => conf['endpoint'],
|
14
|
+
:cname => conf['cname'],
|
15
|
+
:access_key_id => conf['id'],
|
16
|
+
:access_key_secret => conf['key'])
|
17
|
+
@bucket = client.get_bucket(conf['bucket'])
|
18
|
+
@prefix = 'tests/object_key/'
|
19
|
+
@keys = {
|
20
|
+
simple: 'simple_key',
|
21
|
+
chinese: '杭州・中国',
|
22
|
+
space: '是 空格 yeah +-/\\&*#',
|
23
|
+
invisible: '' << 1 << 10 << 12 << 7,
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_key(sym)
|
28
|
+
@prefix + @keys[sym]
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_simple
|
32
|
+
key = get_key(:simple)
|
33
|
+
@bucket.put_object(key)
|
34
|
+
all = @bucket.list_objects(prefix: @prefix).map(&:key)
|
35
|
+
assert_includes all, key
|
36
|
+
assert_equal key, @bucket.get_object(key).key
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_chinese
|
40
|
+
key = get_key(:chinese)
|
41
|
+
@bucket.put_object(key)
|
42
|
+
all = @bucket.list_objects(prefix: @prefix).map(&:key)
|
43
|
+
assert_includes all, key
|
44
|
+
assert_equal key, @bucket.get_object(key).key
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_space
|
48
|
+
key = get_key(:space)
|
49
|
+
@bucket.put_object(key)
|
50
|
+
all = @bucket.list_objects(prefix: @prefix).map(&:key)
|
51
|
+
assert_includes all, key
|
52
|
+
assert_equal key, @bucket.get_object(key).key
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_invisible
|
56
|
+
key = get_key(:invisible)
|
57
|
+
@bucket.put_object(key)
|
58
|
+
all = @bucket.list_objects(prefix: @prefix).map(&:key)
|
59
|
+
assert_includes all, key
|
60
|
+
assert_equal key, @bucket.get_object(key).key
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_batch_delete
|
64
|
+
keys = @keys.map { |k, _| get_key(k) }
|
65
|
+
keys.each { |k| @bucket.put_object(k) }
|
66
|
+
ret = @bucket.batch_delete_objects(keys)
|
67
|
+
assert_equal keys, ret
|
68
|
+
all = @bucket.list_objects(prefix: @prefix).map(&:key)
|
69
|
+
assert all.empty?, all.to_s
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'yaml'
|
3
|
+
$LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__))
|
4
|
+
require 'aliyun/oss'
|
5
|
+
|
6
|
+
class TestResumable < Minitest::Test
|
7
|
+
def setup
|
8
|
+
Aliyun::OSS::Logging.set_log_level(Logger::DEBUG)
|
9
|
+
conf_file = '~/.oss.yml'
|
10
|
+
conf = YAML.load(File.read(File.expand_path(conf_file)))
|
11
|
+
client = Aliyun::OSS::Client.new(
|
12
|
+
:endpoint => conf['endpoint'],
|
13
|
+
:cname => conf['cname'],
|
14
|
+
:access_key_id => conf['id'],
|
15
|
+
:access_key_secret => conf['key'])
|
16
|
+
@bucket = client.get_bucket(conf['bucket'])
|
17
|
+
@prefix = 'tests/resumable/'
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_key(k)
|
21
|
+
@prefix + k
|
22
|
+
end
|
23
|
+
|
24
|
+
def random_string(n)
|
25
|
+
(1...n).map { (65 + rand(26)).chr }.join + "\n"
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_correctness
|
29
|
+
key = get_key('resumable')
|
30
|
+
# generate 10M random data
|
31
|
+
File.open('/tmp/x', 'w') do |f|
|
32
|
+
(10 * 1024).times { f.write(random_string(1024)) }
|
33
|
+
end
|
34
|
+
|
35
|
+
@bucket.resumable_upload(key, '/tmp/x', :part_size => 100 * 1024)
|
36
|
+
@bucket.resumable_download(key, '/tmp/y', :part_size => 100 * 1024)
|
37
|
+
|
38
|
+
diff = `diff /tmp/x /tmp/y`
|
39
|
+
assert diff.empty?, diff
|
40
|
+
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aliyun-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tianlong Wu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -115,8 +115,15 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files:
|
117
117
|
- README.md
|
118
|
+
- CHANGELOG.md
|
118
119
|
files:
|
120
|
+
- CHANGELOG.md
|
119
121
|
- README.md
|
122
|
+
- examples/aliyun/oss/bucket.rb
|
123
|
+
- examples/aliyun/oss/object.rb
|
124
|
+
- examples/aliyun/oss/resumable_download.rb
|
125
|
+
- examples/aliyun/oss/resumable_upload.rb
|
126
|
+
- examples/aliyun/oss/streaming.rb
|
120
127
|
- lib/aliyun/oss.rb
|
121
128
|
- lib/aliyun/oss/bucket.rb
|
122
129
|
- lib/aliyun/oss/client.rb
|
@@ -143,6 +150,11 @@ files:
|
|
143
150
|
- spec/aliyun/oss/object_spec.rb
|
144
151
|
- spec/aliyun/oss/service_spec.rb
|
145
152
|
- spec/aliyun/oss/util_spec.rb
|
153
|
+
- tests/test_content_type.rb
|
154
|
+
- tests/test_large_file.rb
|
155
|
+
- tests/test_multipart.rb
|
156
|
+
- tests/test_object_key.rb
|
157
|
+
- tests/test_resumable.rb
|
146
158
|
homepage: https://gitlab.alibaba-inc.com/oss/ruby-sdk
|
147
159
|
licenses:
|
148
160
|
- MIT
|
@@ -178,4 +190,9 @@ test_files:
|
|
178
190
|
- spec/aliyun/oss/object_spec.rb
|
179
191
|
- spec/aliyun/oss/service_spec.rb
|
180
192
|
- spec/aliyun/oss/util_spec.rb
|
193
|
+
- tests/test_content_type.rb
|
194
|
+
- tests/test_large_file.rb
|
195
|
+
- tests/test_multipart.rb
|
196
|
+
- tests/test_object_key.rb
|
197
|
+
- tests/test_resumable.rb
|
181
198
|
has_rdoc:
|