Compare commits

..
9 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
Liang Tao a70b6f5313 添加list接口。 2014-05-05 20:55:23 +08:00
6 changed files with 86 additions and 9 deletions
+8
View File
@@ -1,5 +1,13 @@
## 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)
+1 -1
View File
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
qiniu (6.3.1)
qiniu (6.4.0)
json (~> 1.7)
mime-types (~> 1.19)
rest-client (~> 1.6)
+2 -1
View File
@@ -20,7 +20,8 @@ module Qiniu
:content_type => 'application/x-www-form-urlencoded',
:auth_url => "https://acc.qbox.me/oauth2/token",
:rs_host => "http://rs.qiniu.com",
:up_host => "http://upload.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",
:access_key => "",
+60 -1
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
@@ -86,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)
@@ -102,6 +160,7 @@ module Qiniu
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
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 = 3
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