qiniu_jxb 6.2.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.
Files changed (48) hide show
  1. data/.gitignore +18 -0
  2. data/.rspec +1 -0
  3. data/.travis.yml +9 -0
  4. data/CHANGELOG.md +118 -0
  5. data/Gemfile +8 -0
  6. data/Gemfile.lock +37 -0
  7. data/LICENSE +22 -0
  8. data/README.md +47 -0
  9. data/Rakefile +21 -0
  10. data/docs/README.md +790 -0
  11. data/lib/qiniu-rs.rb +2 -0
  12. data/lib/qiniu.rb +209 -0
  13. data/lib/qiniu/abstract.rb +22 -0
  14. data/lib/qiniu/adt.rb +46 -0
  15. data/lib/qiniu/auth.rb +234 -0
  16. data/lib/qiniu/config.rb +58 -0
  17. data/lib/qiniu/exceptions.rb +120 -0
  18. data/lib/qiniu/fop.rb +4 -0
  19. data/lib/qiniu/http.rb +137 -0
  20. data/lib/qiniu/image.rb +38 -0
  21. data/lib/qiniu/log.rb +15 -0
  22. data/lib/qiniu/management.rb +128 -0
  23. data/lib/qiniu/misc.rb +33 -0
  24. data/lib/qiniu/pfop.rb +124 -0
  25. data/lib/qiniu/resumable_upload.rb +319 -0
  26. data/lib/qiniu/storage.rb +5 -0
  27. data/lib/qiniu/tokens/access_token.rb +21 -0
  28. data/lib/qiniu/tokens/download_token.rb +31 -0
  29. data/lib/qiniu/tokens/qbox_token.rb +38 -0
  30. data/lib/qiniu/tokens/upload_token.rb +47 -0
  31. data/lib/qiniu/upload.rb +138 -0
  32. data/lib/qiniu/utils.rb +109 -0
  33. data/lib/qiniu/version.rb +17 -0
  34. data/qiniu.gemspec +29 -0
  35. data/spec/qiniu/abstract_spec.rb +30 -0
  36. data/spec/qiniu/auth_spec.rb +81 -0
  37. data/spec/qiniu/image_logo_for_test.png +0 -0
  38. data/spec/qiniu/image_spec.rb +89 -0
  39. data/spec/qiniu/management_spec.rb +156 -0
  40. data/spec/qiniu/misc_spec.rb +59 -0
  41. data/spec/qiniu/pfop_spec.rb +89 -0
  42. data/spec/qiniu/qiniu_spec.rb +329 -0
  43. data/spec/qiniu/tokens/qbox_token_spec.rb +29 -0
  44. data/spec/qiniu/upload_spec.rb +308 -0
  45. data/spec/qiniu/utils_spec.rb +49 -0
  46. data/spec/qiniu/version_spec.rb +10 -0
  47. data/spec/spec_helper.rb +19 -0
  48. metadata +220 -0
@@ -0,0 +1,329 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'digest/sha1'
4
+ require 'spec_helper'
5
+ require 'qiniu'
6
+ require 'qiniu/exceptions'
7
+
8
+ module Qiniu
9
+ describe Qiniu do
10
+
11
+ before :all do
12
+ @bucket = 'RubySDK-Test'
13
+ @bucket = make_unique_bucket(@bucket)
14
+
15
+ @test_image_bucket = @bucket
16
+
17
+ ### 尝试创建Bucket
18
+ result = Qiniu.mkbucket(@bucket)
19
+ puts result.inspect
20
+
21
+ @key = Digest::SHA1.hexdigest Time.now.to_s
22
+ @key = make_unique_key_in_bucket(@key)
23
+
24
+ @key2 = @key + rand(100).to_s
25
+ #@domain = @bucket + '.dn.qbox.me'
26
+
27
+ @test_image_key = 'image_logo_for_test.png'
28
+ local_file = File.expand_path('./' + @test_image_key, File.dirname(__FILE__))
29
+ puts local_file.inspect
30
+ upopts = {:scope => @test_image_bucket, :expires_in => 3600, :customer => "why404@gmail.com"}
31
+ uptoken = Qiniu.generate_upload_token(upopts)
32
+ data = Qiniu.upload_file :uptoken => uptoken, :file => local_file, :bucket => @test_image_bucket, :key => @test_image_key
33
+ puts data.inspect
34
+ end
35
+
36
+ after :all do
37
+ ### 不删除Bucket以备下次使用
38
+ end
39
+
40
+ context ".buckets" do
41
+ it "should works" do
42
+ result = Qiniu.buckets
43
+ result.should_not be_false
44
+ puts result.inspect
45
+ end
46
+ end
47
+
48
+ context ".set_protected" do
49
+ it "should works" do
50
+ result = Qiniu.set_protected(@bucket, 1)
51
+ result.should_not be_false
52
+ puts result.inspect
53
+ end
54
+ end
55
+
56
+ context ".set_separator" do
57
+ it "should works" do
58
+ result = Qiniu.set_separator(@bucket, "-")
59
+ result.should_not be_false
60
+ puts result.inspect
61
+ end
62
+ end
63
+
64
+ context ".set_style" do
65
+ it "should works" do
66
+ result = Qiniu.set_style(@bucket, "small.jpg", "imageMogr/auto-orient/thumbnail/!120x120r/gravity/center/crop/!120x120/quality/80")
67
+ result.should_not be_false
68
+ puts result.inspect
69
+ end
70
+ end
71
+
72
+ context ".unset_style" do
73
+ it "should works" do
74
+ result = Qiniu.unset_style(@bucket, "small.jpg")
75
+ result.should_not be_false
76
+ puts result.inspect
77
+ end
78
+ end
79
+
80
+ context ".upload_file" do
81
+ it "should works" do
82
+ uptoken_opts = {:scope => @bucket, :escape => 0}
83
+ upload_opts = {
84
+ :uptoken => Qiniu.generate_upload_token(uptoken_opts),
85
+ :file => __FILE__,
86
+ :bucket => @bucket,
87
+ :key => @key,
88
+ :enable_crc32_check => true
89
+ }
90
+ result = Qiniu.upload_file(upload_opts)
91
+ result.should_not be_false
92
+ puts result.inspect
93
+ end
94
+
95
+ it "should raise MissingArgsError" do
96
+ uptoken_opts = {:scope => @bucket, :escape => 0}
97
+ upload_opts = {
98
+ :uptoken => Qiniu.generate_upload_token(uptoken_opts),
99
+ :file => __FILE__,
100
+ :key => @key,
101
+ :enable_crc32_check => true
102
+ }
103
+ lambda { Qiniu.upload_file(upload_opts) }.should raise_error(MissingArgsError)
104
+ end
105
+
106
+ it "should raise NoSuchFileError" do
107
+ uptoken_opts = {:scope => @bucket, :escape => 0}
108
+ upload_opts = {
109
+ :uptoken => Qiniu.generate_upload_token(uptoken_opts),
110
+ :file => 'no_this_file',
111
+ :bucket => @bucket,
112
+ :key => @key,
113
+ :enable_crc32_check => true
114
+ }
115
+ lambda { Qiniu.upload_file(upload_opts) }.should raise_error(NoSuchFileError)
116
+ end
117
+ end
118
+
119
+ context ".resumable_upload_file" do
120
+ it "should works" do
121
+ # generate bigfile for testing
122
+ localfile = "test_bigfile"
123
+ File.open(localfile, "w"){|f| 5242888.times{f.write(rand(9).to_s)}}
124
+ key = Digest::SHA1.hexdigest(localfile+Time.now.to_s)
125
+ # generate the upload token
126
+ uptoken_opts = {:scope => @bucket, :expires_in => 3600, :customer => "why404@gmail.com", :escape => 0}
127
+ uptoken = Qiniu.generate_upload_token(uptoken_opts)
128
+ # uploading
129
+ upload_opts = {
130
+ :uptoken => uptoken,
131
+ :file => localfile,
132
+ :bucket => @bucket,
133
+ :key => key
134
+ }
135
+ #uploading
136
+ result1 = Qiniu.upload_file(upload_opts)
137
+ #drop the bigfile
138
+ File.unlink(localfile) if File.exists?(localfile)
139
+ #expect
140
+ puts result1.inspect
141
+ result1.should_not be_false
142
+ result1.should_not be_empty
143
+ #stat
144
+ result2 = Qiniu.stat(@bucket, key)
145
+ puts result2.inspect
146
+ result2.should_not be_false
147
+ #delete
148
+ result3 = Qiniu.delete(@bucket, key)
149
+ puts result3.inspect
150
+ result3.should_not be_false
151
+ end
152
+ end
153
+
154
+ context ".stat" do
155
+ it "should works" do
156
+ result = Qiniu.stat(@bucket, @key)
157
+ result.should_not be_false
158
+ result.should_not be_empty
159
+ puts result.inspect
160
+ end
161
+ end
162
+
163
+ context ".get" do
164
+ it "should works" do
165
+ result = Qiniu.get(@bucket, @key, "qiniu_spec.rb", 10)
166
+ result.should_not be_false
167
+ result.should_not be_empty
168
+ puts result.inspect
169
+ end
170
+ end
171
+
172
+ context ".download" do
173
+ it "should works" do
174
+ result = Qiniu.download(@bucket, @key, "rs_spec.rb", 10)
175
+ result.should_not be_false
176
+ result.should_not be_empty
177
+ puts result.inspect
178
+ end
179
+ end
180
+
181
+ context ".batch" do
182
+ it "should works" do
183
+ result = Qiniu.batch("stat", @bucket, [@key])
184
+ result.should_not be_false
185
+ result.should_not be_empty
186
+ puts result.inspect
187
+ end
188
+ end
189
+
190
+ context ".batch_stat" do
191
+ it "should works" do
192
+ result = Qiniu.batch_stat(@bucket, [@key])
193
+ result.should_not be_false
194
+ result.should_not be_empty
195
+ puts result.inspect
196
+ end
197
+ end
198
+
199
+ context ".batch_get" do
200
+ it "should works" do
201
+ result = Qiniu.batch_get(@bucket, [@key])
202
+ result.should_not be_false
203
+ result.should_not be_empty
204
+ puts result.inspect
205
+ end
206
+ end
207
+
208
+ context ".batch_download" do
209
+ it "should works" do
210
+ result = Qiniu.batch_download(@bucket, [@key])
211
+ result.should_not be_false
212
+ result.should_not be_empty
213
+ puts result.inspect
214
+ end
215
+ end
216
+
217
+ =begin
218
+ context ".batch_copy" do
219
+ it "should works" do
220
+ result = Qiniu.batch_copy [@bucket, @key, @bucket, @key2]
221
+ result.should_not be_false
222
+
223
+ #result2 = Qiniu.stat(@bucket, @key2)
224
+ #result2.should_not be_false
225
+ end
226
+ end
227
+
228
+ context ".batch_move" do
229
+ it "should works" do
230
+ result = Qiniu.batch_move [@bucket, @key, @bucket, @key2]
231
+ result.should_not be_false
232
+
233
+ #result2 = Qiniu.stat(@bucket, @key2)
234
+ #result2.should_not be_false
235
+
236
+ result3 = Qiniu.batch_move [@bucket, @key2, @bucket, @key]
237
+ result3.should_not be_false
238
+ end
239
+ end
240
+ =end
241
+
242
+ context ".move" do
243
+ it "should works" do
244
+ result = Qiniu.move(@bucket, @key, @bucket, @key2)
245
+ result.should_not be_false
246
+
247
+ result2 = Qiniu.stat(@bucket, @key2)
248
+ result2.should_not be_false
249
+
250
+ result3 = Qiniu.move(@bucket, @key2, @bucket, @key)
251
+ result3.should_not be_false
252
+ end
253
+ end
254
+
255
+ context ".copy" do
256
+ it "should works" do
257
+ result = Qiniu.copy(@bucket, @key, @bucket, @key2)
258
+ result.should_not be_false
259
+
260
+ result3 = Qiniu.delete(@bucket, @key2)
261
+ result3.should_not be_false
262
+ end
263
+ end
264
+
265
+ context ".delete" do
266
+ it "should works" do
267
+ result = Qiniu.delete(@bucket, @key)
268
+ result.should_not be_false
269
+ end
270
+ end
271
+
272
+ context ".image_info" do
273
+ it "should works" do
274
+ data = Qiniu.get(@test_image_bucket, @test_image_key)
275
+ data.should_not be_false
276
+ data.should_not be_empty
277
+ puts data.inspect
278
+ result = Qiniu.image_info(data["url"])
279
+ result.should_not be_false
280
+ result.should_not be_empty
281
+ puts result.inspect
282
+ end
283
+ end
284
+
285
+ context ".image_mogrify_save_as" do
286
+ it "should works" do
287
+ data = Qiniu.get(@test_image_bucket, @test_image_key)
288
+ data.should_not be_false
289
+ data.should_not be_empty
290
+ puts data.inspect
291
+
292
+ dest_key = "cropped-" + @test_image_key
293
+ src_img_url = data["url"]
294
+ mogrify_options = {
295
+ :thumbnail => "!120x120>",
296
+ :gravity => "center",
297
+ :crop => "!120x120a0a0",
298
+ :quality => 85,
299
+ :rotate => 45,
300
+ :format => "jpg",
301
+ :auto_orient => true
302
+ }
303
+ result2 = Qiniu.image_mogrify_save_as(@test_image_bucket, dest_key, src_img_url, mogrify_options)
304
+ result2.should_not be_false
305
+ result2.should_not be_empty
306
+ puts result2.inspect
307
+ end
308
+ end
309
+
310
+ context ".generate_upload_token" do
311
+ it "should works" do
312
+ data = Qiniu.generate_upload_token({:scope => @bucket, :expires_in => 3600, :escape => 0})
313
+ data.should_not be_empty
314
+ puts data.inspect
315
+ data.split(":").length.should == 3
316
+ end
317
+ end
318
+
319
+ context ".generate_download_token" do
320
+ it "should works" do
321
+ data = Qiniu.generate_download_token({:expires_in => 1, :pattern => 'http://*.dn.qbox.me/*'})
322
+ data.should_not be_empty
323
+ puts data.inspect
324
+ data.split(":").length.should == 3
325
+ end
326
+ end
327
+
328
+ end
329
+ end # module Qiniu
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+ require 'qiniu/tokens/qbox_token'
5
+
6
+ module Qiniu
7
+ module RS
8
+ describe QboxToken do
9
+ before :all do
10
+ @qbox_token = QboxToken.new(:url => 'www.qiniu.com?key1=value1',
11
+ :params => { :key2 => 'value2' })
12
+ @qbox_token.access_key = 'access_key'
13
+ @qbox_token.secret_key = 'secret_key'
14
+ end
15
+
16
+ context "#generate_token" do
17
+ it "should generate token" do
18
+ @qbox_token.generate_token.should_not be_empty
19
+ end
20
+ end
21
+
22
+ context "#generate_signature" do
23
+ it "should generate signature" do
24
+ @qbox_token.generate_signature.should == "www.qiniu.com?key1=value1\nkey2=value2"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,308 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # vim: sw=2 ts=2
3
+
4
+ require 'spec_helper'
5
+ require 'qiniu/auth'
6
+ require 'qiniu/storage'
7
+ require 'digest/sha1'
8
+
9
+ module Qiniu
10
+ module Storage
11
+ describe Storage do
12
+
13
+ before :all do
14
+ @bucket = 'RubySDK-Test-Storage'
15
+ @bucket = make_unique_bucket(@bucket)
16
+
17
+ ### 尝试创建Bucket
18
+ result = Qiniu.mkbucket(@bucket)
19
+ puts result.inspect
20
+
21
+ @key = Digest::SHA1.hexdigest((Time.now.to_i+rand(100)).to_s)
22
+ @key = make_unique_key_in_bucket(@key)
23
+ puts "key=#{@key}"
24
+
25
+ @localfile_5m = "5M.txt"
26
+ File.open(@localfile_5m, "w"){|f| 5242888.times{ f.write(rand(9).to_s) }}
27
+ @key_5m = Digest::SHA1.hexdigest(@localfile_5m+Time.now.to_s)
28
+ @key_5m = make_unique_key_in_bucket(@key_5m)
29
+ puts "key_5m=#{@key_5m}"
30
+
31
+ @localfile_4m = "4M.txt"
32
+ File.open(@localfile_4m, "w"){|f| (1 << 22).times{ f.write(rand(9).to_s) }}
33
+ @key_4m = Digest::SHA1.hexdigest(@localfile_4m+Time.now.to_s)
34
+ @key_4m = make_unique_key_in_bucket(@key_4m)
35
+ puts "key_4m=#{@key_4m}"
36
+
37
+ @localfile_8m = "8M.txt"
38
+ File.open(@localfile_8m, "w"){|f| (1 << 23).times{ f.write(rand(9).to_s) }}
39
+ @key_8m = Digest::SHA1.hexdigest(@localfile_8m+Time.now.to_s)
40
+ @key_8m = make_unique_key_in_bucket(@key_8m)
41
+ puts "key_8m=#{@key_8m}"
42
+
43
+ @localfile_1m = "1M.txt"
44
+ File.open(@localfile_1m, "w"){|f| (1 << 20).times{ f.write(rand(9).to_s) }}
45
+ @key_1m = Digest::SHA1.hexdigest(@localfile_1m+Time.now.to_s)
46
+ @key_1m = make_unique_key_in_bucket(@key_1m)
47
+ puts "key_1m=#{@key_1m}"
48
+ end
49
+
50
+ after :all do
51
+ ### 清除本地临时文件
52
+ File.unlink(@localfile_5m) if File.exists?(@localfile_5m)
53
+ File.unlink(@localfile_4m) if File.exists?(@localfile_4m)
54
+ File.unlink(@localfile_8m) if File.exists?(@localfile_8m)
55
+ File.unlink(@localfile_1m) if File.exists?(@localfile_1m)
56
+
57
+ ### 不删除Bucket以备下次使用
58
+ end
59
+
60
+ ### 测试单文件直传
61
+ context ".upload_with_token" do
62
+ it "should works" do
63
+ upopts = {:scope => @bucket, :expires_in => 3600, :customer => "why404@gmail.com"}
64
+ uptoken = Qiniu.generate_upload_token(upopts)
65
+ code, data, raw_headers = Qiniu::Storage.upload_with_token(
66
+ uptoken,
67
+ __FILE__,
68
+ @bucket,
69
+ @key,
70
+ nil,
71
+ nil,
72
+ nil,
73
+ true
74
+ )
75
+ code.should == 200
76
+ puts data.inspect
77
+ puts raw_headers.inspect
78
+ end
79
+ end
80
+
81
+ context ".stat" do
82
+ it "should exists" do
83
+ code, data = Qiniu::Storage.stat(@bucket, @key)
84
+ puts data.inspect
85
+ code.should == 200
86
+ end
87
+ end
88
+
89
+ context ".delete" do
90
+ it "should works" do
91
+ code, data = Qiniu::Storage.delete(@bucket, @key)
92
+ puts data.inspect
93
+ code.should == 200
94
+ end
95
+ end
96
+
97
+ context ".upload_with_token_2" do
98
+ it "should works" do
99
+ upopts = {:scope => @bucket, :expires_in => 3600, :endUser => "why404@gmail.com"}
100
+ uptoken = Qiniu.generate_upload_token(upopts)
101
+
102
+ code, data, raw_headers = Qiniu::Storage.upload_with_token_2(
103
+ uptoken,
104
+ __FILE__,
105
+ @key
106
+ )
107
+
108
+ code.should == 200
109
+ puts data.inspect
110
+ puts raw_headers.inspect
111
+ end
112
+ end # .upload_with_token_2
113
+
114
+ context ".stat" do
115
+ it "should exists" do
116
+ code, data = Qiniu::Storage.stat(@bucket, @key)
117
+ puts data.inspect
118
+ code.should == 200
119
+ end
120
+ end
121
+
122
+ context ".delete" do
123
+ it "should works" do
124
+ code, data = Qiniu::Storage.delete(@bucket, @key)
125
+ puts data.inspect
126
+ code.should == 200
127
+ end
128
+ end
129
+
130
+ context ".upload_with_put_policy" do
131
+ it "should works" do
132
+ pp = Qiniu::Auth::PutPolicy.new(@bucket, @key)
133
+ pp.end_user = "why404@gmail.com"
134
+ puts 'put_policy=' + pp.to_json
135
+
136
+ code, data, raw_headers = Qiniu::Storage.upload_with_put_policy(
137
+ pp,
138
+ __FILE__,
139
+ @key + '-not-equal'
140
+ )
141
+ code.should_not == 200
142
+ puts data.inspect
143
+ puts raw_headers.inspect
144
+
145
+ code, data, raw_headers = Qiniu::Storage.upload_with_put_policy(
146
+ pp,
147
+ __FILE__,
148
+ @key
149
+ )
150
+
151
+ code.should == 200
152
+ puts data.inspect
153
+ puts raw_headers.inspect
154
+ end
155
+ end # .upload_with_put_policy
156
+
157
+ context ".stat" do
158
+ it "should exists" do
159
+ code, data = Qiniu::Storage.stat(@bucket, @key)
160
+ puts data.inspect
161
+ code.should == 200
162
+ end
163
+ end
164
+
165
+ context ".delete" do
166
+ it "should works" do
167
+ code, data = Qiniu::Storage.delete(@bucket, @key)
168
+ puts data.inspect
169
+ code.should == 200
170
+ end
171
+ end
172
+
173
+ ### 测试断点续上传
174
+ context ".resumable_upload_with_token" do
175
+ it "should works" do
176
+ upopts = {:scope => @bucket, :expires_in => 3600, :customer => "why404@gmail.com"}
177
+ uptoken = Qiniu.generate_upload_token(upopts)
178
+ code, data, raw_headers = Qiniu::Storage.resumable_upload_with_token(
179
+ uptoken,
180
+ @localfile_5m,
181
+ @bucket,
182
+ @key_5m
183
+ )
184
+ (code/100).should == 2
185
+ puts data.inspect
186
+ puts raw_headers.inspect
187
+ puts "key_5m=#{@key_5m}"
188
+ end
189
+ end
190
+
191
+ context ".stat" do
192
+ it "should exists" do
193
+ code, data = Qiniu::Storage.stat(@bucket, @key_5m)
194
+ puts data.inspect
195
+ code.should == 200
196
+ end
197
+ end
198
+
199
+ context ".delete" do
200
+ it "should works" do
201
+ code, data = Qiniu::Storage.delete(@bucket, @key_5m)
202
+ puts data.inspect
203
+ code.should == 200
204
+ end
205
+ end
206
+
207
+ context ".resumable_upload_with_token2" do
208
+ it "should works" do
209
+ upopts = {:scope => @bucket, :expires_in => 3600, :customer => "why404@gmail.com"}
210
+ uptoken = Qiniu.generate_upload_token(upopts)
211
+ code, data, raw_headers = Qiniu::Storage.resumable_upload_with_token(
212
+ uptoken,
213
+ @localfile_4m,
214
+ @bucket,
215
+ @key_4m
216
+ )
217
+ (code/100).should == 2
218
+ puts data.inspect
219
+ puts raw_headers.inspect
220
+ puts "key_4m=#{@key_4m}"
221
+ end
222
+ end
223
+
224
+ context ".stat" do
225
+ it "should exists" do
226
+ code, data = Qiniu::Storage.stat(@bucket, @key_4m)
227
+ puts data.inspect
228
+ code.should == 200
229
+ end
230
+ end
231
+
232
+ context ".delete" do
233
+ it "should works" do
234
+ code, data = Qiniu::Storage.delete(@bucket, @key_4m)
235
+ puts data.inspect
236
+ code.should == 200
237
+ end
238
+ end
239
+
240
+ context ".resumable_upload_with_token3" do
241
+ it "should works" do
242
+ upopts = {:scope => @bucket, :expires_in => 3600, :customer => "why404@gmail.com"}
243
+ uptoken = Qiniu.generate_upload_token(upopts)
244
+ code, data, raw_headers = Qiniu::Storage.resumable_upload_with_token(
245
+ uptoken,
246
+ @localfile_8m,
247
+ @bucket,
248
+ @key_8m
249
+ )
250
+ (code/100).should == 2
251
+ puts data.inspect
252
+ puts raw_headers.inspect
253
+ puts "key_8m=#{@key_8m}"
254
+ end
255
+ end
256
+
257
+ context ".stat" do
258
+ it "should exists" do
259
+ code, data = Qiniu::Storage.stat(@bucket, @key_8m)
260
+ puts data.inspect
261
+ code.should == 200
262
+ end
263
+ end
264
+
265
+ context ".delete" do
266
+ it "should works" do
267
+ code, data = Qiniu::Storage.delete(@bucket, @key_8m)
268
+ puts data.inspect
269
+ code.should == 200
270
+ end
271
+ end
272
+
273
+ context ".resumable_upload_with_token4" do
274
+ it "should works" do
275
+ upopts = {:scope => @bucket, :expires_in => 3600, :customer => "why404@gmail.com"}
276
+ uptoken = Qiniu.generate_upload_token(upopts)
277
+ code, data, raw_headers = Qiniu::Storage.resumable_upload_with_token(
278
+ uptoken,
279
+ @localfile_1m,
280
+ @bucket,
281
+ @key_1m
282
+ )
283
+ (code/100).should == 2
284
+ puts data.inspect
285
+ puts raw_headers.inspect
286
+ puts "key_1m=#{@key_1m}"
287
+ end
288
+ end
289
+
290
+ context ".stat" do
291
+ it "should exists" do
292
+ code, data = Qiniu::Storage.stat(@bucket, @key_1m)
293
+ puts data.inspect
294
+ code.should == 200
295
+ end
296
+ end
297
+
298
+ context ".delete" do
299
+ it "should works" do
300
+ code, data = Qiniu::Storage.delete(@bucket, @key_1m)
301
+ puts data.inspect
302
+ code.should == 200
303
+ end
304
+ end
305
+
306
+ end
307
+ end # module Storage
308
+ end # module Qiniu