From c91c5e424638d4fe345352aec14cabbb0281b16b Mon Sep 17 00:00:00 2001 From: Liang Tao Date: Fri, 28 Mar 2014 16:05:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E4=B8=AD=E5=AF=B9Storage.upload=5Fwith=5Ftoken=5F2=E7=9A=84?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=9B=B4=E6=8D=A2=E4=B8=BAStorage.upload=5Fw?= =?UTF-8?q?ith=5Fput=5Fpolicy=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/qiniu/auth_spec.rb | 11 ++++------- spec/qiniu/management_spec.rb | 14 ++++++-------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/spec/qiniu/auth_spec.rb b/spec/qiniu/auth_spec.rb index 0054e4f..afb54bc 100755 --- a/spec/qiniu/auth_spec.rb +++ b/spec/qiniu/auth_spec.rb @@ -31,13 +31,10 @@ module Qiniu puts "key=#{key}" ### 上传测试文件 - upopts = {:scope => @bucket, :expires_in => 3600, :endUser => "why404@gmail.com"} - uptoken = Qiniu.generate_upload_token(upopts) - - code, data, raw_headers = Qiniu::Storage.upload_with_token_2( - uptoken, - __FILE__, - key + pp = Auth::PutPolicy.new(@bucket, key) + code, data, raw_headers = Qiniu::Storage.upload_with_put_policy( + pp, + __FILE__ ) code.should == 200 puts data.inspect diff --git a/spec/qiniu/management_spec.rb b/spec/qiniu/management_spec.rb index 7023cc0..abd1fff 100755 --- a/spec/qiniu/management_spec.rb +++ b/spec/qiniu/management_spec.rb @@ -1,4 +1,5 @@ # -*- encoding: utf-8 -*- +# vim: sw=2 ts=2 require 'digest/sha1' require 'spec_helper' @@ -29,15 +30,12 @@ module Qiniu end ### 准备数据 - context ".upload_with_token_2" do + context ".prepare_file" do it "should works" do - upopts = {:scope => @bucket, :expires_in => 3600, :endUser => "why404@gmail.com"} - uptoken = Qiniu.generate_upload_token(upopts) - - code, data, raw_headers = Qiniu::Storage.upload_with_token_2( - uptoken, - __FILE__, - @key + pp = Auth::PutPolicy.new(@bucket, @key) + code, data, raw_headers = Qiniu::Storage.upload_with_put_policy( + pp, + __FILE__ ) code.should == 200 puts data.inspect