mirror of
https://github.com/wahyd4/ruby-sdk.git
synced 2026-08-09 04:46:10 +10:00
删除过时的IO.put_auth与IO.upload_file组合。
This commit is contained in:
@@ -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],
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user