Compare commits

..
50 Commits
Author SHA1 Message Date
Bai Long 7d65b22e2e [ci skip] 2014-11-28 18:02:00 +08:00
Bai Long 8b000c0a98 Merge pull request #111 from BluntBlade/master
更新接口代码
2014-11-28 18:00:35 +08:00
Liang Tao f93e50c838 更新 ChangeLog 。 2014-11-28 16:38:47 +08:00
Liang Tao b8f43a1ded 为 upload 的最新版本接口添加 content-type/mimeType 设置方法。 2014-11-28 16:22:58 +08:00
Liang Tao 804fa4d5b6 添加rsf_host。 2014-08-01 17:08:05 +08:00
Liang Tao 0f2466d4c2 Merge branch 'master' of github.com:qiniu/ruby-sdk into list
Conflicts:
	lib/qiniu/config.rb
2014-07-29 10:20:02 +08:00
Bai Long 93c3cb8dea update version [ci skip] 2014-07-24 21:27:48 +08:00
Bai Long 3cccf69b61 update log [ci skip] 2014-07-24 21:26:35 +08:00
Bai Long b98cec1433 Merge pull request #103 from longbai/update_dependency
update test
2014-07-24 17:23:44 +08:00
longbai a29cfe5a71 update test 2014-07-24 14:38:59 +08:00
Bai Long 17f69da758 Update CHANGELOG.md 2014-07-11 15:55:04 +08:00
Bai Long 7280ca139a Merge pull request #100 from dp90219/master
a mistake. change `persistent_ops` to `persistentOps` and so on
2014-07-09 22:16:17 +08:00
Bai Long bc30779647 Merge pull request #99 from coaku/b_xzk_upload_qiniu_com
#9891
2014-07-09 21:55:13 +08:00
liupeng b6ab98b238 Merge branch 'master' of https://github.com/dp90219/ruby-sdk 2014-07-09 14:09:44 +08:00
liupeng db62d9bcd3 a mistake. change params[:persistent_ops] to params[:persistentOps] and so on 2014-07-09 14:06:16 +08:00
xuzhaokui 089ebb2354 upload.qiniu.com 2014-07-09 11:27:46 +08:00
liupeng e97582e370 a mistake. change persistent_ops to persistentOps and so on 2014-07-09 10:20:22 +08:00
Bai Long c01a43f3d9 Merge pull request #97 from dp90219/master
去除generate_upload_token 中旧的async_options, 添加 persistent_ops
2014-07-08 20:51:50 +08:00
Bai Long 4142c0182a Merge pull request #98 from BluntBlade/master
为过时方法添加说明。
2014-07-08 20:50:48 +08:00
Liang Tao 3d9d50c3c5 为过时方法添加说明。 2014-07-08 17:20:12 +08:00
liupeng e0c4a14e20 去除generate_upload_token 中旧的async_options, 添加 persistent_ops, persistent_notify_url, persistent_pipeline 2014-07-08 17:09:41 +08:00
Bai Long 67c4d63a05 Merge pull request #95 from BluntBlade/master
添加 authorize_download_url_2 方法,对包含中文或其它 utf-8 字符的Key做下载授权。
2014-07-01 15:41:30 +08:00
Liang Tao 5ffe9daf58 更新版本信息。 2014-07-01 15:27:35 +08:00
Liang Tao a6debbec49 Merge branch 'master' of github.com:qiniu/ruby-sdk 2014-07-01 15:04:55 +08:00
Liang Tao 58dfe18328 添加 authorize_download_url_2 方法,对包含中文或其它 utf-8 字符的Key做下载授权。 2014-07-01 14:40:48 +08:00
Liang Tao 1222559c71 添加 schema 和 port 参数。 2014-07-01 11:57:45 +08:00
Liang Tao 31cbf3a6fd 添加针对中文Key的私有资源下载URL授权方法。 2014-06-30 16:08:46 +08:00
Bai Long 3504d39cd0 Update README.md 2014-06-20 22:11:03 +08:00
Bai Long 2322bbcd9c Update Gemfile.lock 2014-06-20 21:24:15 +08:00
Bai Long 1ece11ea89 Update version.rb 2014-06-20 21:23:36 +08:00
Bai Long 48abc7f7c1 Update CHANGELOG.md 2014-06-20 21:21:01 +08:00
Bai Long 4aca5af37e Update CHANGELOG.md
调整user agent
2014-06-20 21:20:23 +08:00
Bai Long 35661ebcbf Update config.rb 2014-06-20 21:12:21 +08:00
Bai Long c87b75d3cf Merge pull request #94 from longbai/user-agent
User agent
2014-06-20 20:59:57 +08:00
longbai 328306814a add new user agent 2014-06-20 20:40:09 +08:00
longbai e2d8a07882 update site 2014-06-20 20:39:51 +08:00
Bai Long 8f11a43123 Merge pull request #93 from BluntBlade/master
为PutPolicy添加persistentPipeline参数。
2014-06-06 13:19:29 +08:00
Liang Tao 9d8f684eec 补充版本更新信息。 2014-06-06 12:18:14 +08:00
Liang Tao 244735a3f2 为PutPolicy添加persistentPipeline参数。 2014-06-06 12:15:00 +08:00
Bai Long 53d5f1bb4b Merge pull request #92 from BluntBlade/master
一些同步更新
2014-06-04 15:28:07 +08:00
Liang Tao de31e33460 添加Pull Request URL。 2014-06-04 14:58:24 +08:00
Liang Tao 01711a6fd4 Merge branch 'master' of github.com:BluntBlade/ruby-sdk 2014-06-04 14:53:35 +08:00
Liang Tao 5735dce6e9 Merge branch 'master' of github.com:qiniu/ruby-sdk 2014-06-04 14:48:17 +08:00
Liang Tao 788e21720b 添加版本说明。 2014-06-04 14:48:16 +08:00
Liang Tao 1f6e9ba47b 为authorize_download_url()添加:fop参数,以便生成含FOP指令的授权下载URL。 2014-06-04 14:40:23 +08:00
Liang Tao a424c79dd6 添加pipeline参数,用于指定命名转码队列。 2014-06-04 14:16:20 +08:00
Bai Long 7e66297bf9 Merge pull request #91 from longbai/remove-transform
remove transform
2014-05-30 19:59:32 +08:00
longbai ba91ee2377 remove transform 2014-05-30 18:44:04 +08:00
Liang Tao a70b6f5313 添加list接口。 2014-05-05 20:55:23 +08:00
Liang Tao 417b717bc5 去除未公开的参数。 2014-05-05 16:44:36 +08:00
22 changed files with 188 additions and 113 deletions
+2 -2
View File
@@ -5,5 +5,5 @@ rvm:
- 2.1.1
- jruby-19mode
before_script:
- export QINIU_ACCESS_KEY=LGRqJsjX7LAvtdtX6hhyxs861lS57HwnOQmJsOuX
- export QINIU_SECRET_KEY=g_OxhuN5iJ1O7BoA6YdXyF6zSszk34UZFKDfdIIW
- export QINIU_ACCESS_KEY=QWYn5TFQsLLU1pL5MFEmX3s5DmHdUThav9WyOWOm
- export QINIU_SECRET_KEY=Bxckh6FA-Fbs9Yt3i3cbKVK22UPBmAOHJcL95pGz
+31
View File
@@ -1,5 +1,36 @@
## CHANGE LOG
### v6.4.0
- 为 put_with_put_policy() 添加 opts 参数,允许使用 :content_type 键指定上传文件的 mime type。 [https://github.com/qiniu/ruby-sdk/pull/111](https://github.com/qiniu/ruby-sdk/pull/111)
### v6.3.2
- 调整上传host。 [https://github.com/qiniu/ruby-sdk/pull/103](https://github.com/qiniu/ruby-sdk/pull/103)
### v6.3.1
- 为过期方法添加说明。 [https://github.com/qiniu/ruby-sdk/pull/98](https://github.com/qiniu/ruby-sdk/pull/98)
- 修改上传域名。 [https://github.com/qiniu/ruby-sdk/pull/99](https://github.com/qiniu/ruby-sdk/pull/99)
- 增加pfop参数。 [https://github.com/qiniu/ruby-sdk/pull/100](https://github.com/qiniu/ruby-sdk/pull/100)
### v6.3.0
- 添加 authorize_download_url_2 方法,对包含中文或其它 utf-8 字符的 Key 做下载授权。 [https://github.com/qiniu/ruby-sdk/pull/95](https://github.com/qiniu/ruby-sdk/pull/95)
### v6.2.4
- 调整User Agent。 [https://github.com/qiniu/ruby-sdk/pull/94](https://github.com/qiniu/ruby-sdk/pull/94)
### v6.2.3
- 为上传策略添加`persistentPipeline`参数,用于指明使用哪个命名转码队列。 [https://github.com/qiniu/ruby-sdk/pull/93](https://github.com/qiniu/ruby-sdk/pull/93)
### v6.2.2
- 为/pfop接口添加`pipeline`参数,用于指明使用哪个命名转码队列。 [https://github.com/qiniu/ruby-sdk/pull/92](https://github.com/qiniu/ruby-sdk/pull/92)
- 为authorize_download_url()添加`:fop`参数,用于生成含数据处理指令的授权下载URL。
### v6.2.1
- 去除已废弃的publish/unpublish接口。 [https://github.com/qiniu/ruby-sdk/pull/90](https://github.com/qiniu/ruby-sdk/pull/90) (#8143)
+1 -1
View File
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
qiniu (6.2.1)
qiniu (6.4.0)
json (~> 1.7)
mime-types (~> 1.19)
rest-client (~> 1.6)
+2 -2
View File
@@ -2,7 +2,7 @@
## 关于
此 Ruby SDK 适用于 Ruby 1.8.x, 1.9.x, 2.0.x, jruby, rbx, ree 版本,基于 [七牛云存储官方API](http://developer.qiniu.com/docs/v6/index.html) 构建。使用此 SDK 构建您的网络应用程序,能让您以非常便捷地方式将数据安全地存储到七牛云存储上。无论您的网络应用是一个网站程序,还是包括从云端(服务端程序)到终端(手持设备应用)的架构的服务或应用,通过七牛云存储及其 SDK,都能让您应用程序的终端用户高速上传和下载,同时也让您的服务端更加轻盈。
此 Ruby SDK 适用于 Ruby 1.9.x, 2.0.x, 2.1.x, jruby版本,基于 [七牛云存储官方API](http://developer.qiniu.com/docs/v6/index.html) 构建。使用此 SDK 构建您的网络应用程序,能让您以非常便捷地方式将数据安全地存储到七牛云存储上。无论您的网络应用是一个网站程序,还是包括从云端(服务端程序)到终端(手持设备应用)的架构的服务或应用,通过七牛云存储及其 SDK,都能让您应用程序的终端用户高速上传和下载,同时也让您的服务端更加轻盈。
## 状态
@@ -15,7 +15,7 @@
在您 Ruby 应用程序的 `Gemfile` 文件中,添加如下一行代码:
gem 'qiniu', '~> 6.1.0'
gem 'qiniu', '~> 6.3.1'
然后,在应用程序所在的目录下,可以运行 `bundle` 安装依赖包:
+35 -7
View File
@@ -3,6 +3,7 @@
require 'hmac-sha1'
require 'uri'
require 'cgi'
require 'qiniu/exceptions'
@@ -51,15 +52,14 @@ module Qiniu
:callback_body => "callbackBody" ,
:persistent_ops => "persistentOps" ,
:persistent_notify_url => "persistentNotifyUrl" ,
:transform => "transform" ,
:persistent_pipeline => "persistentPipeline" ,
# 数值类型参数
:deadline => "deadline" ,
:insert_only => "insertOnly" ,
:fsize_limit => "fsizeLimit" ,
:detect_mime => "detectMime" ,
:mime_limit => "mimeLimit" ,
:fop_timeout => "fopTimeout"
:mime_limit => "mimeLimit"
} # PARAMS
public
@@ -140,16 +140,29 @@ module Qiniu
access_key = Config.settings[:access_key]
secret_key = Config.settings[:secret_key]
download_url = url
### URL变换:追加FOP指令
if args[:fop].is_a?(String) && args[:fop] != '' then
if download_url.index('?').is_a?(Fixnum) then
# 已有参数
download_url = "#{download_url}&#{args[:fop]}"
else
# 尚无参数
download_url = "#{download_url}?#{args[:fop]}"
end
end
### 授权期计算
e = Auth.calculate_deadline(args[:expires_in], args[:deadline])
### URL变换:追加授权期参数
if url.index('?').is_a?(Fixnum) then
if download_url.index('?').is_a?(Fixnum) then
# 已有参数
download_url = "#{url}&e=#{e}"
download_url = "#{download_url}&e=#{e}"
else
# 尚无参数
download_url = "#{url}?e=#{e}"
download_url = "#{download_url}?e=#{e}"
end
### 生成数字签名
@@ -163,6 +176,21 @@ module Qiniu
return "#{download_url}&token=#{dntoken}"
end # authorize_download_url
### 对包含中文或其它 utf-8 字符的 Key 做下载授权
def authorize_download_url_2(domain, key, args = EMPTY_ARGS)
url_encoded_key = CGI::escape(key)
schema = args[:schema] || "http"
port = args[:port]
if port.nil? then
download_url = "#{schema}://#{domain}/#{url_encoded_key}"
else
download_url = "#{schema}://#{domain}:#{port}/#{url_encoded_key}"
end
return authorize_download_url(download_url, args)
end # authorize_download_url_2
def generate_acctoken(url, body = '')
### 提取AK/SK信息
access_key = Config.settings[:access_key]
@@ -184,7 +212,7 @@ module Qiniu
# 如果有Body,则也加上
# (仅限于mime == "application/x-www-form-urlencoded"的情况)
if body.is_a?(String) && !body.empty?
signing_str += body
signing_str += body
end
### 生成数字签名
+3 -4
View File
@@ -15,16 +15,15 @@ module Qiniu
class << self
DEFAULT_OPTIONS = {
:user_agent => 'Qiniu-RS-Ruby-SDK-' + Version.to_s + '()',
:user_agent => 'QiniuRuby/' + Version.to_s + ' ('+RUBY_PLATFORM+')' + ' Ruby/'+ RUBY_VERSION,
:method => :post,
:content_type => 'application/x-www-form-urlencoded',
:auth_url => "https://acc.qbox.me/oauth2/token",
:rs_host => "http://rs.qiniu.com",
:rsf_host => "http://rsf.qbox.me",
:up_host => "http://up.qiniu.com",
:pub_host => "http://pu.qbox.me:10200",
:eu_host => "http://eu.qbox.me",
:client_id => "a75604760c4da4caaa456c0c5895c061c3065c5a",
:client_secret => "75df554a39f58accb7eb293b550fa59618674b7d",
:access_key => "",
:secret_key => "",
:auto_reconnect => true,
@@ -32,7 +31,7 @@ module Qiniu
:block_size => 1024*1024*4,
:chunk_size => 1024*256,
:enable_debug => true,
:tmpdir => Dir.tmpdir + File::SEPARATOR + 'Qiniu-RS-Ruby-SDK'
:tmpdir => Dir.tmpdir + File::SEPARATOR + 'QiniuRuby'
}
REQUIRED_OPTION_KEYS = [:access_key, :secret_key]
+62 -24
View File
@@ -1,10 +1,48 @@
# -*- encoding: utf-8 -*-
# vim: sw=2 ts=2
require 'qiniu/adt'
require 'qiniu/http'
module Qiniu
module Storage
class ListPolicy
include ADT::Policy
private
def initialize(bucket,
limit = 1000,
prefix = '',
delimiter = '')
@bucket = bucket
@limit = limit
@prefix = prefix
@delimiter = delimiter
end # initialize
public
PARAMS = {
# 字符串类型参数
:bucket => "bucket",
:prefix => "prefix",
:delimiter => "delimiter",
:marker => "marker",
# 数值类型参数
:limit => "limit"
} # PARAMS
PARAMS.each_pair do |key, fld|
attr_accessor key
end
def params
return PARAMS
end # params
alias :to_s :to_query_string
end # class ListPolicy
class << self
include Utils
@@ -14,22 +52,6 @@ module Qiniu
return HTTP.management_post(url)
end # buckets
PRIVATE_BUCKET = 0
PUBLIC_BUCKET = 1
def mkbucket(bucket_name, is_public = PUBLIC_BUCKET)
url = Config.settings[:rs_host] + '/mkbucket2/' + bucket_name + '/public/' + is_public.to_s
return HTTP.management_post(url)
end # mkbucket
def make_a_private_bucket(bucket_name)
return mkbucket(bucket_name, PRIVATE_BUCKET)
end # make_a_private_bucket
def make_a_public_bucket(bucket_name)
return mkbucket(bucket_name, PUBLIC_BUCKET)
end # make_a_public_bucket
def stat(bucket, key)
url = Config.settings[:rs_host] + '/stat/' + encode_entry_uri(bucket, key)
return HTTP.management_post(url)
@@ -60,11 +82,6 @@ module Qiniu
return HTTP.management_post(url)
end # delete
def drop(bucket)
url = Config.settings[:rs_host] + "/drop/#{bucket}"
return HTTP.management_post(url)
end # drop
def batch(command, bucket, keys)
execs = []
keys.each do |key|
@@ -107,6 +124,26 @@ module Qiniu
save_as(bucket, key, source_image_url, mogrify_params_string)
end # image_mogrify_save_as
def list(list_policy)
url = Config.settings[:rsf_host] + '/list?' + list_policy.to_query_string()
resp_code, resp_body, resp_headers = HTTP.management_post(url)
if resp_code == 0 || resp_code > 299 then
has_more = false
return resp_code, resp_body, resp_headers, has_more, list_policy
end
has_more = (resp_body['marker'].is_a?(String) && resp_body['marker'] != '')
if has_more then
new_list_policy = list_policy.clone()
new_list_policy.marker = resp_body['marker']
else
new_list_policy = list_policy
end
return resp_code, resp_body, resp_headers, has_more, new_list_policy
end # list
private
def _generate_cp_or_mv_opstr(command, source_bucket, source_key, target_bucket, target_key)
@@ -117,12 +154,13 @@ module Qiniu
def _batch_cp_or_mv(command, *op_args)
execs = []
op_args.each do |e|
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
end
url = Config.settings[:rs_host] + "/batch"
return HTTP.management_post(url, execs.join("&"))
end # _batch_cp_or_mv
end
end # class << self
end # module Storage
end # module Qiniu
+1
View File
@@ -30,6 +30,7 @@ module Qiniu
:key => "key",
:fops => "fops",
:notify_url => "notifyURL",
:pipeline => "pipeline",
# 数值类型参数
:force => "force"
+2
View File
@@ -4,6 +4,8 @@ require 'hmac-sha1'
require 'qiniu/config'
require 'qiniu/utils'
### AccessToken 类已经过时,请改用 Qiniu::Auth.generate_acctoken 方法 ###
module Qiniu
class AccessToken
+3
View File
@@ -4,6 +4,9 @@ require 'json'
require 'qiniu/tokens/access_token'
require 'qiniu/utils'
### DownloadToken 类已经过时,请改用 Qiniu::Auth.authorize_download_url 方法 ###
### 或 Qiniu::Auth.authorize_download_url_2 方法 ###
module Qiniu
class DownloadToken < AccessToken
+10 -2
View File
@@ -4,6 +4,8 @@ require 'json'
require 'qiniu/tokens/access_token'
require 'qiniu/utils'
### UploadToken 类已经过时,请改用 Qiniu::Auth.generate_uptoken 方法 ###
module Qiniu
class UploadToken < AccessToken
@@ -19,7 +21,9 @@ module Qiniu
@callback_body_type = opts[:callback_body_type]
@customer = opts[:customer]
@escape = opts[:escape]
@async_options = opts[:async_options]
@persistent_ops = opts[:persistent_ops]
@persistent_notify_url = opts[:persistent_notify_url]
@persistent_pipeline = opts[:persistent_pipeline]
@return_body = opts[:return_body]
@return_url = opts[:return_url]
end
@@ -31,9 +35,13 @@ module Qiniu
params[:callbackBodyType] = @callback_body_type if !@callback_body_type.nil? && !@callback_body_type.empty?
params[:customer] = @customer if !@customer.nil? && !@customer.empty?
params[:escape] = 1 if @escape == 1 || @escape == true
params[:asyncOps] = @async_options if !@async_options.nil? && !@async_options.empty?
params[:returnBody] = @return_body if !@return_body.nil? && !@return_body.empty?
params[:returnUrl] = @return_url if !@return_url.nil? && !@return_url.empty?
params[:persistentOps] = @persistent_ops if !@persistent_ops.nil? && !@persistent_ops.empty?
params[:persistentNotifyUrl] = @persistent_notify_url if !@persistent_notify_url.nil? && !@persistent_notify_url.empty?
params[:persistentPipeline] = @persistent_pipeline if !@persistent_pipeline.nil? && !@persistent_pipeline.empty?
Utils.urlsafe_base64_encode(params.to_json)
end
Executable → Regular
+13 -4
View File
@@ -47,15 +47,23 @@ module Qiniu
def upload_with_token_2(uptoken,
local_file,
key = nil,
x_vars = nil)
x_vars = nil,
opts = {})
### 构造URL
url = Config.settings[:up_host]
url[/\/*$/] = ''
url += '/'
### 构造HTTP Body
file = File.new(local_file, 'rb')
if not opts[:content_type].nil?
file.define_singleton_method("content_type") do
opts[:content_type]
end
end
post_data = {
:file => File.new(local_file, 'rb'),
:file => file,
:multipart => true,
}
if not uptoken.nil?
@@ -84,13 +92,14 @@ module Qiniu
def upload_with_put_policy(put_policy,
local_file,
key = nil,
x_vars = nil)
x_vars = nil,
opts = {})
uptoken = Auth.generate_uptoken(put_policy)
if key.nil? then
key = put_policy.key
end
return upload_with_token_2(uptoken, local_file, key, x_vars)
return upload_with_token_2(uptoken, local_file, key, x_vars, opts)
end # upload_with_put_policy
private
+2 -2
View File
@@ -3,8 +3,8 @@
module Qiniu
module Version
MAJOR = 6
MINOR = 2
PATCH = 1
MINOR = 4
PATCH = 0
# Returns a version string by joining <tt>MAJOR</tt>, <tt>MINOR</tt>, and <tt>PATCH</tt> with <tt>'.'</tt>
#
# Example
+9 -10
View File
@@ -1,4 +1,5 @@
# -*- encoding: utf-8 -*-
# vim: sw=2 ts=2
require 'spec_helper'
require 'qiniu/auth'
@@ -6,20 +7,13 @@ require 'qiniu/storage'
require 'digest/sha1'
module Qiniu
module Auth
module Auth
describe Auth do
before :all do
@bucket = 'RubySDK-Test-Private'
@bucket = make_unique_bucket(@bucket)
### 尝试创建Bucket
result = Qiniu::Storage.make_a_private_bucket(@bucket)
puts result.inspect
@bucket = 'rubysdk'
end
after :all do
### 不删除Bucket以备下次使用
end
### 测试私有资源下载
@@ -56,7 +50,12 @@ module Qiniu
result.body.should_not be_empty
### 授权下载地址(带参数)
download_url = Qiniu::Auth.authorize_download_url(url + '?download/a.m3u8')
download_url = Qiniu::Auth.authorize_download_url(
url,
{
:fop => 'download/a.m3u8'
}
)
puts "download_url=#{download_url}"
result = RestClient.get(download_url)
+1 -10
View File
@@ -10,15 +10,7 @@ module Qiniu
describe Fop do
before :all do
### 复用RubySDK-Test-Storage空间
@bucket = 'RubySDK-Test-Storage'
@bucket = make_unique_bucket(@bucket)
### 尝试创建空间
result = Qiniu.mkbucket(@bucket)
puts result.inspect
@bucket = 'rubysdk'
pic_fname = "image_logo_for_test.png"
@key = make_unique_key_in_bucket(pic_fname)
@@ -57,7 +49,6 @@ module Qiniu
end
after :all do
### 不删除Bucket以备下次使用
end
context ".info" do
+1 -7
View File
@@ -12,12 +12,7 @@ module Qiniu
describe Storage do
before :all do
@bucket = 'RubySDK-Test-Management'
@bucket = make_unique_bucket(@bucket)
### 尝试创建Bucket
result = Qiniu.mkbucket(@bucket)
puts result.inspect
@bucket = 'rubysdk'
@key = Digest::SHA1.hexdigest((Time.now.to_i+rand(100)).to_s)
@key = make_unique_key_in_bucket(@key)
@@ -26,7 +21,6 @@ module Qiniu
end
after :all do
### 不删除Bucket以备下次使用
end
### 准备数据
+1 -7
View File
@@ -10,16 +10,10 @@ module Qiniu
describe Misc do
before :all do
### 复用RubySDK-Test-Management空间
@bucket = 'RubySDK-Test-Management'
@bucket = make_unique_bucket(@bucket)
result = Qiniu.mkbucket(@bucket)
puts result.inspect
@bucket = 'rubysdk'
end
after :all do
### 不删除Bucket以备下次使用
end
context ".set_protected" do
+1 -10
View File
@@ -12,15 +12,7 @@ module Qiniu
describe Persistance do
before :all do
### 复用RubySDK-Test-Storage空间
@bucket = 'RubySDK-Test-Storage'
@bucket = make_unique_bucket(@bucket)
### 尝试创建空间
code, data, headers = Qiniu::Storage.make_a_public_bucket(@bucket)
puts code.inspect
puts data.inspect
puts headers.inspect
@bucket = 'rubysdk'
pic_fname = "image_logo_for_test.png"
@key = make_unique_key_in_bucket(pic_fname)
@@ -44,7 +36,6 @@ module Qiniu
end
after :all do
### 不删除Bucket以备下次使用
end
context ".pfop" do
+1 -7
View File
@@ -9,15 +9,10 @@ module Qiniu
describe Qiniu do
before :all do
@bucket = 'RubySDK-Test'
@bucket = make_unique_bucket(@bucket)
@bucket = 'rubysdk'
@test_image_bucket = @bucket
### 尝试创建Bucket
result = Qiniu.mkbucket(@bucket)
puts result.inspect
@key = Digest::SHA1.hexdigest Time.now.to_s
@key = make_unique_key_in_bucket(@key)
@@ -34,7 +29,6 @@ module Qiniu
end
after :all do
### 不删除Bucket以备下次使用
end
context ".buckets" do
+2 -2
View File
@@ -7,7 +7,7 @@ module Qiniu
module RS
describe QboxToken do
before :all do
@qbox_token = QboxToken.new(:url => 'www.qiniutek.com?key1=value1',
@qbox_token = QboxToken.new(:url => 'www.qiniu.com?key1=value1',
:params => { :key2 => 'value2' })
@qbox_token.access_key = 'access_key'
@qbox_token.secret_key = 'secret_key'
@@ -21,7 +21,7 @@ module Qiniu
context "#generate_signature" do
it "should generate signature" do
@qbox_token.generate_signature.should == "www.qiniutek.com?key1=value1\nkey2=value2"
@qbox_token.generate_signature.should == "www.qiniu.com?key1=value1\nkey2=value2"
end
end
end
+1 -8
View File
@@ -11,12 +11,7 @@ module Qiniu
describe Storage do
before :all do
@bucket = 'RubySDK-Test-Storage'
@bucket = make_unique_bucket(@bucket)
### 尝试创建Bucket
result = Qiniu.mkbucket(@bucket)
puts result.inspect
@bucket = 'rubysdk'
@key = Digest::SHA1.hexdigest((Time.now.to_i+rand(100)).to_s)
@key = make_unique_key_in_bucket(@key)
@@ -53,8 +48,6 @@ module Qiniu
File.unlink(@localfile_4m) if File.exists?(@localfile_4m)
File.unlink(@localfile_8m) if File.exists?(@localfile_8m)
File.unlink(@localfile_1m) if File.exists?(@localfile_1m)
### 不删除Bucket以备下次使用
end
### 测试单文件直传
+4 -4
View File
@@ -26,8 +26,8 @@ module Qiniu
context ".send_request_with" do
it "should works" do
FakeWeb.allow_net_connect = false
FakeWeb.register_uri(:get, "http://docs.qiniutek.com/", :body => {:abc => 123}.to_json)
res = Utils.send_request_with 'http://docs.qiniutek.com/', nil, :method => :get
FakeWeb.register_uri(:get, "http://develoepr.qiniu.com/", :body => {:abc => 123}.to_json)
res = Utils.send_request_with 'http://develoepr.qiniu.com/', nil, :method => :get
res.should == [200, {"abc" => 123}, {}]
end
@@ -35,9 +35,9 @@ module Qiniu
context "upstream return http #{code}" do
it "should raise RestClient::RequestFailed" do
FakeWeb.allow_net_connect = false
FakeWeb.register_uri(:get, "http://docs.qiniutek.com/", :status => code)
FakeWeb.register_uri(:get, "http://develoepr.qiniu.com/", :status => code)
lambda {
res = Utils.send_request_with 'http://docs.qiniutek.com/', nil, :method => :get
res = Utils.send_request_with 'http://develoepr.qiniu.com/', nil, :method => :get
}.should raise_error RestClient::RequestFailed
end
end