Compare commits

...
33 Commits
Author SHA1 Message Date
longbai 98b1dc4fac update version for refresh gems 2014-06-20 22:35:37 +08:00
longbai 67f7011777 update doc 2014-06-20 22:23:26 +08:00
Bai Long f699236afd Merge pull request #89 from BluntBlade/qiniu-rs
去掉publish/unpublish接口的封装函数。
2014-04-20 14:31:22 +08:00
Liang Tao cfa75c7e28 添加PR号。 2014-04-18 16:53:24 +08:00
Liang Tao a031645e3c 去掉publish/unpublish接口的封装函数。 2014-04-18 16:50:18 +08:00
Liang Tao a86786b76c Merge branch 'qiniu-rs' of github.com:qiniu/ruby-sdk into qiniu-rs 2014-04-18 16:44:31 +08:00
Liang Tao c77ec97620 修正另一个可能引发大量重试的Bug点。 2014-04-08 16:52:41 +08:00
Bai Long d62fba8290 Merge pull request #87 from BluntBlade/qiniu-rs
修正一直重试上传出错片的Bug。
2014-04-08 11:00:44 +08:00
Liang Tao 35b1682096 添加版本更新说明。 2014-04-08 10:55:14 +08:00
Liang Tao 5aa5934da7 修正一直重试上传出错片的Bug。 2014-04-08 10:48:25 +08:00
LI Daobing c86e22395b Merge pull request #80 from BluntBlade/qiniu-rs
修正加密密钥方法。
2014-03-11 10:28:30 +08:00
Liang Tao ede5f2400a 恢复到最初的Travis配置。 2014-03-10 18:12:04 +08:00
Liang Tao 5a5adc79f9 修正密钥加密方法(#2)。 2014-03-10 17:51:08 +08:00
Liang Tao fdfee5c2bb 修正加密密钥方法。 2014-03-10 16:41:44 +08:00
LI Daobing 4106a5ddc6 Merge pull request #79 from BluntBlade/qiniu-rs
加密七牛密钥。
2014-03-10 15:47:33 +08:00
Liang Tao 3bb30f1b4f 加密七牛密钥。 2014-03-10 14:41:57 +08:00
LI Daobing 55daca055e Merge pull request #78 from BluntBlade/qiniu-rs
删除rbx测试项目,添加2.0.0和2.1.1测试项目。
2014-03-10 13:41:50 +08:00
Liang Tao 672b8d18cc 删除rbx测试项目,添加2.0.0和2.1.1测试项目。 2014-03-10 13:39:14 +08:00
LI Daobing 83f7939510 Merge pull request #77 from BluntBlade/qiniu-rs
修正授权凭证算法、删除过期SDK函数、修正相关测试用例
2014-03-10 12:58:06 +08:00
Liang Tao c506e410b6 删除过期的Auth函数和相关测试用例。 2014-03-10 11:35:34 +08:00
Liang Tao a7dbcbcee8 修正授权凭证生成算法,并调整测试用例。 2014-03-10 11:09:12 +08:00
LI Daobing 4548061f87 Merge pull request #76 from BluntBlade/qiniu-rs
添加版本更新信息,修正部分文档链接。
2014-03-06 15:39:33 +08:00
Liang Tao 4d7dc24c60 修正版本信息。 2014-03-06 15:36:44 +08:00
Liang Tao ff86b2ac50 添加版本更新信息,修正部分文档链接。 2014-03-06 15:06:32 +08:00
404 f1461c338e Merge pull request #66 from qiniu/v3
rm staus icon
2013-09-27 14:02:29 -07:00
why404 67280b714e rm status icons 2013-09-28 04:51:21 +08:00
404 8f86e6903a Merge pull request #65 from why404/hotfix/v3.4.6
Hotfix/v3.4.6
2013-09-27 12:46:15 -07:00
why404 47cf54069d Gemfile 2013-09-28 03:44:32 +08:00
why404 0bb4edcade fix :pattern requried 2013-09-28 03:42:00 +08:00
404 b1e6235b2e Merge pull request #57 from why404/hotfix/v3.4.5
Gemfile.lock ver fix
2013-07-24 18:24:51 -07:00
why404 e5d2367a27 ver fix 2013-07-25 09:22:56 +08:00
404 3186ba40df Merge pull request #56 from why404/release/v3.4.4
release v3.4.4
2013-07-23 11:12:30 -07:00
why404 c5708424b9 release v3.4.4 2013-07-24 02:09:19 +08:00
17 changed files with 73 additions and 215 deletions
+1 -2
View File
@@ -3,10 +3,9 @@ rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0.0
- jruby-18mode
- jruby-19mode
- rbx-18mode
- rbx-19mode
- jruby-head
- ree
before_script:
+25 -4
View File
@@ -1,14 +1,35 @@
## CHANGE LOG
### v3.4.9
- 去掉publish和unpublish接口的封装函数。 [https://github.com/qiniu/ruby-sdk/pull/89](https://github.com/qiniu/ruby-sdk/pull/89) (#8143)
### v3.4.8
- 修复断点续上传功能中一直重试上传出错片的Bug。[https://github.com/qiniu/ruby-sdk/pull/87](https://github.com/qiniu/ruby-sdk/pull/87) (#7205)
### v3.4.7
- 停止追加新功能,仅进行Bug修正维护。
### v3.4.6
- `Qiniu::RS.generate_download_token()` 方法的 `:pattern` 调整为必选项。
### v3.4.5
- `Qiniu::RS.generate_upload_token()` 方法新增 `:callback_body``return_url` 选项。
- 选项含义参考: <http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html#put-policy-callback-body>
### v3.4.2
- `Qiniu::RS.generate_upload_token()` 方法新增 `:return_body` 选项。
该选项(`:return_body`)可设置文件上传成功后,执行七牛云存储规定的回调API,并以 JSON 响应格式返回其执行结果。参考 [uploadToken 之 returnBody 说明](http://docs.qiniutek.com/v3/api/io/#uploadToken-returnBody)。
该选项(`:return_body`)可设置文件上传成功后,执行七牛云存储规定的回调API,并以 JSON 响应格式返回其执行结果。参考 [uploadToken 之 returnBody 说明](http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html#put-policy-return-body)。
### v3.4.1
增加为上传文件进行预转的选项,参见 [uploadToken 之 asyncOps 说明](http://docs.qiniutek.com/v3/api/io/#uploadToken-asyncOps)
增加为上传文件进行预转的选项,参见 [uploadToken 之 asyncOps 说明](http://docs.qiniu.com/api/v6/put.html#uploadToken-asyncOps)
- `Qiniu::RS.generate_upload_token()` 方法新增 `:async_options` 选项用于进行预转操作。
@@ -35,9 +56,9 @@ Ruby 宿主环境如下
### v3.3.0
私有资源下载新版实现,添加 Qiniu::RS.generate_download_token() 方法。参考 [downloadToken](http://docs.qiniutek.com/v3/api/io/#get)
私有资源下载新版实现,添加 Qiniu::RS.generate_download_token() 方法。参考 [downloadToken](http://developer.qiniu.com/docs/v6/api/reference/security/download-token.html)
详见 [Ruby SDK 使用文档之私有资源下载](http://docs.qiniutek.com/v3/sdk/ruby/#download-private-files)
详见 [Ruby SDK 使用文档之私有资源下载](http://developer.qiniu.com/docs/v6/api/overview/dn/security.html)
### v3.2.2
+3 -3
View File
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
qiniu-rs (3.4.2)
qiniu-rs (3.4.9)
json (~> 1.7)
mime-types (~> 1.19)
rest-client (~> 1.6)
@@ -12,8 +12,8 @@ GEM
specs:
diff-lcs (1.1.3)
fakeweb (1.3.0)
json (1.7.6)
mime-types (1.20.1)
json (1.8.1)
mime-types (1.23)
rake (10.0.3)
rest-client (1.6.7)
mime-types (>= 1.16)
+8 -3
View File
@@ -1,8 +1,13 @@
# Qiniu Resource (Cloud) Storage SDK for Ruby - [![Build Status](https://api.travis-ci.org/qiniu/ruby-sdk.png?branch=master)](https://travis-ci.org/qiniu/ruby-sdk) [![Dependency Status](https://gemnasium.com/why404/qiniu-rs-for-ruby.png)](https://gemnasium.com/why404/qiniu-rs-for-ruby)
# Qiniu Resource (Cloud) Storage SDK for Ruby
# 版本说明
此版本不再进行技术升级,仅做Bug修正维护。
请移步 [https://github.com/qiniu/ruby-sdk](https://github.com/qiniu/ruby-sdk) 查看最新版本。
# 关于
此 Ruby SDK 适用于 Ruby 1.8.x, 1.9.x, jruby, rbx, ree 版本,基于 [七牛云存储官方API](http://docs.qiniutek.com/v3/api/) 构建。使用此 SDK 构建您的网络应用程序,能让您以非常便捷地方式将数据安全地存储到七牛云存储上。无论您的网络应用是一个网站程序,还是包括从云端(服务端程序)到终端(手持设备应用)的架构的服务或应用,通过七牛云存储及其 SDK,都能让您应用程序的终端用户高速上传和下载,同时也让您的服务端更加轻盈。
此 Ruby SDK 适用于 Ruby 1.8.x, 1.9.x, jruby, rbx, ree 版本,基于 [七牛云存储官方API](http://developer.qiniu.com/docs/v6/index.html) 构建。使用此 SDK 构建您的网络应用程序,能让您以非常便捷地方式将数据安全地存储到七牛云存储上。无论您的网络应用是一个网站程序,还是包括从云端(服务端程序)到终端(手持设备应用)的架构的服务或应用,通过七牛云存储及其 SDK,都能让您应用程序的终端用户高速上传和下载,同时也让您的服务端更加轻盈。
## 安装
@@ -20,7 +25,7 @@
## 使用
参考文档:[七牛云存储 Ruby SDK 使用指南](http://docs.qiniutek.com/v3/sdk/ruby/)
参考文档:[七牛云存储 Ruby SDK 使用指南](http://developer.qiniu.com/docs/v6/sdk/ruby-sdk.html)
## 贡献代码
+1 -1
View File
@@ -330,7 +330,7 @@ expires_in
: 可选,数字类型,用于设置上传 URL 的有效期,单位:秒,缺省为 3600 秒,即 1 小时后该下载授权凭证(downloadToken)不再有效。
pattern
: 选,字符串类型,用于设置可匹配的下载链接。参考:[downloadToken pattern 详解](http://docs.qiniutek.com/v3/api/io/#download-token-pattern)
: 选,字符串类型,用于设置可匹配的下载链接。参考:[downloadToken pattern 详解](http://docs.qiniutek.com/v3/api/io/#download-token-pattern)
<a name="other-download-features"></a>
+2 -12
View File
@@ -182,12 +182,12 @@ module Qiniu
end
def batch_copy(*args)
code, data = RS.batch_copy(args)
code, data = RS.batch_copy(*args)
code == StatusOK
end
def batch_move(*args)
code, data = RS.batch_move(args)
code, data = RS.batch_move(*args)
code == StatusOK
end
@@ -204,16 +204,6 @@ module Qiniu
code == StatusOK ? data : false
end
def publish(domain, bucket)
code, data = RS.publish(domain, bucket)
code == StatusOK
end
def unpublish(domain)
code, data = RS.unpublish(domain)
code == StatusOK
end
def drop(bucket)
code, data = RS.drop(bucket)
code == StatusOK
+1 -66
View File
@@ -8,78 +8,13 @@ module Qiniu
class << self
include Utils
def exchange_by_password!(username, password)
@username = username
@password = password
post_data = {
:client_id => Config.settings[:client_id],
:grant_type => "password",
:username => username,
:password => password
}
code, data = http_request Config.settings[:auth_url], post_data
reset_token(data["access_token"], data["refresh_token"]) if Utils.is_response_ok?(code)
[code, data]
end
def exchange_by_refresh_token!(refresh_token)
post_data = {
:client_id => Config.settings[:client_id],
:grant_type => "refresh_token",
:refresh_token => refresh_token
}
code, data = http_request Config.settings[:auth_url], post_data
reset_token(data["access_token"], data["refresh_token"]) if Utils.is_response_ok?(code)
[code, data]
end
def reset_token(access_token, refresh_token)
@access_token = access_token
@refresh_token = refresh_token
end
def call_with_logged_in(url, data, retry_times = 0)
raise MissingAccessToken if @access_token.nil?
code, data = http_request url, data, {:access_token => @access_token}
if code == 401
raise MissingRefreshToken if @refresh_token.nil?
code, data = exchange_by_refresh_token!(@refresh_token)
if code == 401
raise MissingUsernameOrPassword if (@username.nil? || @password.nil?)
code, data = exchange_by_password!(@username, @password)
end
if Utils.is_response_ok?(code)
retry_times += 1
if Config.settings[:auto_reconnect] && retry_times < Config.settings[:max_retry_times]
return call_with_logged_in(url, data, retry_times)
end
end
end
[code, data]
end
def call_with_signature(url, data, retry_times = 0, options = {})
code, data = http_request url, data, options.merge({:qbox_signature_token => generate_qbox_signature(url, data)})
code, data = http_request url, data, options.merge({:qbox_signature_token => generate_qbox_signature(url, data, options[:mime])})
[code, data]
end
def request(url, data = nil, options = {})
begin
if Config.settings[:access_key].empty? || Config.settings[:secret_key].empty?
code, data = Auth.call_with_logged_in(url, data)
else
code, data = Auth.call_with_signature(url, data, 0, options)
end
rescue MissingAccessToken => e
Log.logger.error e
code, data = 401, {}
rescue MissingRefreshToken => e
Log.logger.error e
code, data = 401, {}
rescue MissingUsernameOrPassword => e
Log.logger.error e
code, data = 401, {}
end
[code, data]
end
+2 -2
View File
@@ -20,9 +20,9 @@ module Qiniu
:method => :post,
:content_type => 'application/x-www-form-urlencoded',
:auth_url => "https://acc.qbox.me/oauth2/token",
:rs_host => "http://rs.qbox.me",
:rs_host => "http://rs.qiniu.com",
:io_host => "http://iovip.qbox.me",
:up_host => "http://up.qbox.me",
:up_host => "http://up.qiniu.com",
:pub_host => "http://pu.qbox.me:10200",
:eu_host => "http://eu.qbox.me",
:client_id => "a75604760c4da4caaa456c0c5895c061c3065c5a",
+2 -12
View File
@@ -40,16 +40,6 @@ module Qiniu
Auth.request Config.settings[:rs_host] + '/delete/' + encode_entry_uri(bucket, key)
end
def publish(domain, bucket)
encoded_domain = Utils.urlsafe_base64_encode(domain)
Auth.request Config.settings[:rs_host] + "/publish/#{encoded_domain}/from/#{bucket}"
end
def unpublish(domain)
encoded_domain = Utils.urlsafe_base64_encode(domain)
Auth.request Config.settings[:rs_host] + "/unpublish/#{encoded_domain}"
end
def drop(bucket)
Auth.request Config.settings[:rs_host] + "/drop/#{bucket}"
end
@@ -60,7 +50,7 @@ module Qiniu
encoded_uri = encode_entry_uri(bucket, key)
execs << "op=/#{command}/#{encoded_uri}"
end
Auth.request Config.settings[:rs_host] + "/batch?" + execs.join("&")
Auth.request Config.settings[:rs_host] + "/batch", execs.join("&"), {:mime => "application/x-www-form-urlencoded" }
end
def batch_get(bucket, keys)
@@ -108,7 +98,7 @@ module Qiniu
op_args.each do |e|
execs << 'op=' + _generate_cp_or_mv_opstr(command, e[0], e[1], e[2], e[3]) if e.size == 4
end
Auth.request Config.settings[:rs_host] + "/batch?" + execs.join("&")
Auth.request Config.settings[:rs_host] + "/batch", execs.join("&"), {:mime => "application/x-www-form-urlencoded" }
end
end
+4
View File
@@ -200,6 +200,8 @@ module Qiniu
break
elsif i == retry_times && data["crc32"] != body_crc32
Log.logger.error %Q(Uploading block error. Expected crc32: #{body_crc32}, but got: #{data["crc32"]})
# 上传重试达到上限,直接返回错误
return [code, data]
end
end
elsif progress[:offset] + progress[:restsize] != block_size
@@ -230,6 +232,8 @@ module Qiniu
break
elsif i == retry_times && data["crc32"] != body_crc32
Log.logger.error %Q(Uploading block error. Expected crc32: #{body_crc32}, but got: #{data["crc32"]})
# 上传重试达到上限,直接返回错误
return [code, data]
end
end
end
+4 -1
View File
@@ -127,7 +127,7 @@ module Qiniu
File.open(filepath, "rb") { |f| Zlib.crc32 f.read }
end
def generate_qbox_signature(url, params)
def generate_qbox_signature(url, params, mime = nil)
access_key = Config.settings[:access_key]
secret_key = Config.settings[:secret_key]
uri = URI.parse(url)
@@ -139,6 +139,9 @@ module Qiniu
params_string = generate_query_string(params)
signature += params_string
end
if mime.is_a?(String) && mime == "application/x-www-form-urlencoded" && params.is_a?(String)
signature += params
end
hmac = HMAC::SHA1.new(secret_key)
hmac.update(signature)
encoded_digest = urlsafe_base64_encode(hmac.digest)
+1 -1
View File
@@ -5,7 +5,7 @@ module Qiniu
module Version
MAJOR = 3
MINOR = 4
PATCH = 2
PATCH = 10
# Returns a version string by joining <tt>MAJOR</tt>, <tt>MINOR</tt>, and <tt>PATCH</tt> with <tt>'.'</tt>
#
# Example
+1 -1
View File
@@ -13,7 +13,7 @@ module Qiniu
attr_accessor :pattern, :expires_in
def initialize(opts = {})
@pattern = opts[:pattern] || "*"
@pattern = opts[:pattern]
@expires_in = opts[:expires_in] || 3600
end
+4 -4
View File
@@ -4,10 +4,10 @@ require File.expand_path('../lib/qiniu/rs/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["why404"]
gem.email = ["why404@gmail.com"]
gem.description = %q{Qiniu Resource (Cloud) Storage SDK for Ruby. See: http://docs.qiniutek.com/v3/sdk/ruby/}
gem.summary = %q{Qiniu Resource (Cloud) Storage SDK for Ruby}
gem.homepage = "https://github.com/qiniu/ruby-sdk"
gem.email = ["sdk@qiniu.com"]
gem.description = %q{Deprecated Qiniu Resource (Cloud) Storage SDK for Ruby. Please use new SDK https://rubygems.org/gems/qiniu}
gem.summary = %q{Deprecated Qiniu Resource (Cloud) Storage SDK for Ruby}
gem.homepage = "https://github.com/qiniu/ruby-sdk/tree/qiniu-rs"
gem.files = `git ls-files`.split($\)
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
-58
View File
@@ -1,58 +0,0 @@
# -*- encoding: utf-8 -*-
require 'spec_helper'
require 'qiniu/rs/auth'
module Qiniu
module RS
describe Auth do
before :all do
@username = "qboxtest"
@password = "qboxtest123"
code, data = Qiniu::RS::Auth.exchange_by_password!(@username, @password)
code.should == 200
data.should be_an_instance_of(Hash)
data["access_token"].should_not be_empty
data["refresh_token"].should_not be_empty
data["refresh_token"].should_not be_empty
@access_token = data["access_token"]
@refresh_token = data["refresh_token"]
puts data.inspect
end
context ".exchange_by_password" do
it "should sign in failed when pass a non-existent username" do
code, data = Qiniu::RS::Auth.exchange_by_password!("a_non_existent_user@example.com", "password")
code.should == 401
data["error_code"].should == 11
data["error"].should == "failed_authentication"
puts data.inspect
end
it "should sign in failed when pass a wrong password" do
code, data = Qiniu::RS::Auth.exchange_by_password!(@username, "a-wrong-password")
code.should == 401
data["error_code"].should == 11
data["error"].should == "failed_authentication"
puts data.inspect
end
end
context ".exchange_by_refresh_token" do
it "should works" do
@refresh_token.should_not be_empty
code, data = Qiniu::RS::Auth.exchange_by_refresh_token!(@refresh_token)
code.should == 200
data["access_token"].should_not be_empty
data["refresh_token"].should_not be_empty
data["expires_in"].should_not be_zero
puts data.inspect
end
end
end
end
end
+8 -21
View File
@@ -92,19 +92,24 @@ module Qiniu
context ".batch_copy" do
it "should works" do
code, data = Qiniu::RS::RS.batch_copy [@bucket, @key, @bucket, @key2]
code, data = Qiniu::RS::RS.batch_copy @bucket, @key, @bucket, @key2
code.should == 200
puts data.inspect
#code2, data2 = Qiniu::RS::RS.stat(@bucket, @key2)
#code2.should == 200
#puts data2.inspect
#
code, data = Qiniu::RS::RS.delete(@bucket, @key2)
code.should == 200
puts data.inspect
end
end
context ".batch_move" do
it "should works" do
code, data = Qiniu::RS::RS.batch_move [@bucket, @key, @bucket, @key2]
code, data = Qiniu::RS::RS.batch_move @bucket, @key, @bucket, @key2
code.should == 200
puts data.inspect
@@ -112,30 +117,12 @@ module Qiniu
#code2.should == 200
#puts data2.inspect
code3, data3 = Qiniu::RS::RS.batch_move [@bucket, @key2, @bucket, @key]
code3, data3 = Qiniu::RS::RS.batch_move @bucket, @key2, @bucket, @key
code3.should == 200
puts data3.inspect
end
end
=begin
context ".publish" do
it "should works" do
code, data = Qiniu::RS::RS.publish(@domain, @bucket)
code.should == 200
puts data.inspect
end
end
context ".unpublish" do
it "should works" do
code, data = Qiniu::RS::RS.unpublish(@domain)
code.should == 200
puts data.inspect
end
end
=end
context ".move" do
it "should works" do
code, data = Qiniu::RS::RS.move(@bucket, @key, @bucket, @key2)
+6 -24
View File
@@ -32,9 +32,6 @@ module Qiniu
end
after :all do
#result = Qiniu::RS.unpublish(@domain)
#result.should_not be_false
result1 = Qiniu::RS.drop(@bucket)
puts result1.inspect
result1.should_not be_false
@@ -278,43 +275,28 @@ module Qiniu
end
end
=begin
context ".publish" do
it "should works" do
result = Qiniu::RS.publish(@domain, @bucket)
result.should_not be_false
end
end
=end
=begin
context ".unpublish" do
it "should works" do
result = Qiniu::RS.unpublish(@domain)
result.should_not be_false
end
end
=end
context ".batch_copy" do
it "should works" do
result = Qiniu::RS.batch_copy [@bucket, @key, @bucket, @key2]
result = Qiniu::RS.batch_copy @bucket, @key, @bucket, @key2
result.should_not be_false
#result2 = Qiniu::RS.stat(@bucket, @key2)
#result2.should_not be_false
result = Qiniu::RS.delete @bucket, @key2
result.should_not be_false
end
end
context ".batch_move" do
it "should works" do
result = Qiniu::RS::RS.batch_move [@bucket, @key, @bucket, @key2]
result = Qiniu::RS.batch_move @bucket, @key, @bucket, @key2
result.should_not be_false
#result2 = Qiniu::RS.stat(@bucket, @key2)
#result2.should_not be_false
result3 = Qiniu::RS.batch_move [@bucket, @key2, @bucket, @key]
result3 = Qiniu::RS.batch_move @bucket, @key2, @bucket, @key
result3.should_not be_false
end
end