diff --git a/CHANGELOG.md b/CHANGELOG.md index fb274d6..41a0446 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ - 更新Qiniu::Storage所有上传接口的测试用例,打印HTTP响应Header信息。 +- 删除过时的Qiniu::Storage#put_file方法和相关测试用例。 + +该方法调用的API已过时并逐步废弃,建议用户尽快迁移到Qiniu::Storage#upload_with_token_2方法上。 + ### v6.0.1 - 重新划分命名空间,存储相关归入Qiniu::Storage,数据处理相关归入Qiniu::Fop,杂项相关归入Qiniu::Misc。 diff --git a/lib/qiniu.rb b/lib/qiniu.rb index 49c3658..337b78a 100755 --- a/lib/qiniu.rb +++ b/lib/qiniu.rb @@ -54,16 +54,6 @@ module Qiniu code == StatusOK end - def put_file opts = {} - code, data = Storage.put_file(opts[:file], - opts[:bucket], - opts[:key], - opts[:mime_type], - opts[:note], - opts[:enable_crc32_check]) - code == StatusOK - end - def upload_file opts = {} uncontained_opts = [:uptoken, :file, :bucket, :key] - opts.keys raise MissingArgsError, uncontained_opts unless uncontained_opts.empty? diff --git a/lib/qiniu/config.rb b/lib/qiniu/config.rb index 53216c3..7f230e4 100755 --- a/lib/qiniu/config.rb +++ b/lib/qiniu/config.rb @@ -20,7 +20,6 @@ module Qiniu :content_type => 'application/x-www-form-urlencoded', :auth_url => "https://acc.qbox.me/oauth2/token", :rs_host => "http://rs.qiniu.com", - :io_host => "http://iovip.qbox.me", :up_host => "http://up.qiniu.com", :pub_host => "http://pu.qbox.me:10200", :eu_host => "http://eu.qbox.me", diff --git a/lib/qiniu/upload.rb b/lib/qiniu/upload.rb index 73f9d98..faede91 100755 --- a/lib/qiniu/upload.rb +++ b/lib/qiniu/upload.rb @@ -5,27 +5,6 @@ module Qiniu class << self include Utils - 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 - options = {:content_type => 'application/octet-stream'} - - Auth.request url, ::IO.read(local_file), options - end # put_file - def upload_with_token(uptoken, local_file, bucket, diff --git a/spec/qiniu/management_spec.rb b/spec/qiniu/management_spec.rb index 34ab775..7023cc0 100755 --- a/spec/qiniu/management_spec.rb +++ b/spec/qiniu/management_spec.rb @@ -29,9 +29,16 @@ module Qiniu end ### 准备数据 - context ".put_file" do + context ".upload_with_token_2" do it "should works" do - code, data = Storage.put_file(__FILE__, @bucket, @key, 'application/x-ruby', 'customMeta', true) + 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 + ) code.should == 200 puts data.inspect end diff --git a/spec/qiniu/qiniu_spec.rb b/spec/qiniu/qiniu_spec.rb index 86a014e..1136432 100755 --- a/spec/qiniu/qiniu_spec.rb +++ b/spec/qiniu/qiniu_spec.rb @@ -37,17 +37,6 @@ module Qiniu ### 不删除Bucket以备下次使用 end - context ".put_file" do - it "should works" do - result = Qiniu.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.buckets diff --git a/spec/qiniu/upload_spec.rb b/spec/qiniu/upload_spec.rb index f06e81d..e344c21 100755 --- a/spec/qiniu/upload_spec.rb +++ b/spec/qiniu/upload_spec.rb @@ -57,38 +57,6 @@ module Qiniu end ### 测试单文件直传 - context ".put_file" do - it "should works" do - code, data, raw_headers = Qiniu::Storage.put_file( - __FILE__, - @bucket, - @key, - 'application/x-ruby', - 'customMeta', - true - ) - code.should == 200 - puts data.inspect - puts raw_headers.inspect - end - end - - context ".stat" do - it "should exists" do - code, data = Qiniu::Storage.stat(@bucket, @key) - puts data.inspect - code.should == 200 - end - end - - context ".delete" do - it "should works" do - code, data = Qiniu::Storage.delete(@bucket, @key) - puts data.inspect - code.should == 200 - end - end - context ".upload_with_token" do it "should works" do upopts = {:scope => @bucket, :expires_in => 3600, :customer => "why404@gmail.com"}