删除过时的IO.put_auth与IO.upload_file组合。

This commit is contained in:
Liang Tao
2014-02-08 11:50:53 +08:00
parent ef9c90c7c5
commit 08f36221b7
5 changed files with 14 additions and 93 deletions
-17
View File
@@ -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],
-17
View File
@@ -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
-13
View File
@@ -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)
+3 -10
View File
@@ -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
+11 -36
View File
@@ -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}