mirror of
https://github.com/wahyd4/ruby-sdk.git
synced 2026-08-09 12:56:21 +10:00
Merge branch 'master' into auth.renew
This commit is contained in:
@@ -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。
|
||||
|
||||
@@ -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?
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
|
||||
+2
-2
@@ -74,8 +74,8 @@ module Qiniu
|
||||
else
|
||||
data = {}
|
||||
body = response.respond_to?(:body) ? response.body : {}
|
||||
raw_headers = response.respond_to?(:raw_headers) ? response.raw_headers : {}
|
||||
data = safe_json_parse(body) unless body.empty?
|
||||
raw_headers = response.raw_headers
|
||||
end
|
||||
[code, data, raw_headers]
|
||||
end # send_request_with
|
||||
@@ -100,8 +100,8 @@ module Qiniu
|
||||
res = e.response
|
||||
code = res.code.to_i if res.respond_to? :code
|
||||
body = res.respond_to?(:body) ? res.body : ""
|
||||
raw_headers = res.respond_to?(:raw_headers) ? res.raw_headers : {}
|
||||
data = safe_json_parse(body) unless body.empty?
|
||||
raw_headers = response.raw_headers
|
||||
end
|
||||
[code, data, raw_headers]
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"}
|
||||
|
||||
Reference in New Issue
Block a user