diff --git a/lib/qiniu/rs.rb b/lib/qiniu/rs.rb index fda7d68..3b7323b 100755 --- a/lib/qiniu/rs.rb +++ b/lib/qiniu/rs.rb @@ -70,23 +70,6 @@ module Qiniu end =end - def put_auth(expires_in = nil, callback_url = nil) - code, data = IO.put_auth(expires_in, callback_url) - code == StatusOK ? data["url"] : false - end - - def upload opts = {} - code, data = IO.upload_file(opts[:url], - opts[:file], - opts[:bucket], - opts[:key], - opts[:mime_type], - opts[:note], - opts[:callback_params], - opts[:enable_crc32_check]) - code == StatusOK - end - def put_file opts = {} code, data = IO.put_file(opts[:file], opts[:bucket], diff --git a/lib/qiniu/rs/io.rb b/lib/qiniu/rs/io.rb index cccabe3..8c7739d 100755 --- a/lib/qiniu/rs/io.rb +++ b/lib/qiniu/rs/io.rb @@ -10,23 +10,6 @@ module Qiniu class << self include Utils - def put_auth(expires_in = nil, callback_url = nil) - url = Config.settings[:io_host] + "/put-auth/" - url += "#{expires_in}" if !expires_in.nil? && expires_in > 0 - if !callback_url.nil? && !callback_url.empty? - encoded_callback_url = Utils.urlsafe_base64_encode(callback_url) - url += "/callback/#{encoded_callback_url}" - end - Auth.request(url) - end - - def upload_file(url, local_file, bucket, key = nil, mime_type = nil, custom_meta = nil, callback_params = nil, enable_crc32_check = false) - action_params = _generate_action_params(local_file, bucket, key, mime_type, custom_meta, enable_crc32_check) - callback_params = {:bucket => bucket, :key => key, :mime_type => mime_type} if callback_params.nil? - callback_query_string = Utils.generate_query_string(callback_params) - Utils.upload_multipart_data(url, local_file, action_params, callback_query_string) - end - def put_file(local_file, bucket, key = nil, mime_type = nil, custom_meta = nil, enable_crc32_check = false) action_params = _generate_action_params(local_file, bucket, key, mime_type, custom_meta, enable_crc32_check) url = Config.settings[:io_host] + action_params diff --git a/spec/qiniu/rs/io_spec.rb b/spec/qiniu/rs/io_spec.rb index 51075b9..3b0f7bb 100755 --- a/spec/qiniu/rs/io_spec.rb +++ b/spec/qiniu/rs/io_spec.rb @@ -24,19 +24,6 @@ module Qiniu result.should_not be_false end - context ".upload_file" do - it "should works" do - code, data = Qiniu::RS::IO.put_auth() - code.should == 200 - data["url"].should_not be_empty - data["expiresIn"].should_not be_zero - puts data.inspect - code2, data2 = Qiniu::RS::IO.upload_file(data["url"], __FILE__, @bucket, @key) - code2.should == 200 - puts data2.inspect - end - end - context ".put_file" do it "should works" do code, data = Qiniu::RS::IO.put_file(__FILE__, @bucket, @key, 'application/x-ruby', 'customMeta', true) diff --git a/spec/qiniu/rs/rs_spec.rb b/spec/qiniu/rs/rs_spec.rb index 67569ae..3954c85 100755 --- a/spec/qiniu/rs/rs_spec.rb +++ b/spec/qiniu/rs/rs_spec.rb @@ -27,18 +27,11 @@ module Qiniu code.should == 200 end - context "IO.upload_file" do + context ".put_file" do it "should works" do - code, data = Qiniu::RS::IO.put_auth() - puts data.inspect + code, data = Qiniu::RS::IO.put_file(__FILE__, @bucket, @key, 'application/x-ruby', 'customMeta', true) code.should == 200 - data["url"].should_not be_empty - data["expiresIn"].should_not be_zero - @put_url = data["url"] - - code2, data2 = Qiniu::RS::IO.upload_file(@put_url, __FILE__, @bucket, @key) - puts data2.inspect - code2.should == 200 + puts data.inspect end end diff --git a/spec/qiniu/rs_spec.rb b/spec/qiniu/rs_spec.rb index 22a1699..8c0dd80 100755 --- a/spec/qiniu/rs_spec.rb +++ b/spec/qiniu/rs_spec.rb @@ -44,6 +44,17 @@ module Qiniu result2.should_not be_false end + context ".put_file" do + it "should works" do + result = Qiniu::RS.put_file :file => __FILE__, + :bucket => @bucket, + :key => @key, + :mime_type => 'application/x-ruby', + :enable_crc32_check => true + result.should be_true + end + end + context ".buckets" do it "should works" do result = Qiniu::RS.buckets @@ -105,42 +116,6 @@ module Qiniu end =end - context ".put_auth" do - it "should works" do - result = Qiniu::RS.put_auth(10) - result.should_not be_false - result.should_not be_empty - puts result.inspect - end - end - - context ".upload" do - it "should works" do - put_url = Qiniu::RS.put_auth(10) - put_url.should_not be_false - put_url.should_not be_empty - puts put_url.inspect - result = Qiniu::RS.upload :url => put_url, - :file => __FILE__, - :bucket => @bucket, - :key => @key, - :mime_type => 'application/x-ruby', - :enable_crc32_check => true - result.should be_true - end - end - - context ".put_file" do - it "should works" do - result = Qiniu::RS.put_file :file => __FILE__, - :bucket => @bucket, - :key => @key, - :mime_type => 'application/x-ruby', - :enable_crc32_check => true - result.should be_true - end - end - context ".upload_file" do it "should works" do uptoken_opts = {:scope => @bucket, :escape => 0}