Merge pull request #34 from why404/feature/upload_async_options

v3.4.1 - add :async_options for uploadToken
This commit is contained in:
404
2013-01-14 09:20:44 -08:00
7 changed files with 23 additions and 5 deletions
+6
View File
@@ -1,5 +1,11 @@
## CHANGE LOG
### v3.4.1
增加为上传文件进行预转的选项,参见 [uploadToken 之 asyncOps 说明](http://docs.qiniutek.com/v3/api/io/#uploadToken-asyncOps)
- `Qiniu::RS.generate_upload_token()` 方法新增 `:async_options` 选项用于进行预转操作。
### v3.4.0
增加文件复制/移动方法,包括批量复制/移动文件
+1 -1
View File
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
qiniu-rs (3.4.0)
qiniu-rs (3.4.1)
json (~> 1.7)
mime-types (~> 1.19)
rest-client (~> 1.6)
+5 -1
View File
@@ -125,7 +125,8 @@ title: Ruby SDK 使用指南 | 七牛云存储
:callback_url => callback_url,
:callback_body_type => callback_body_type,
:customer => end_user_id,
:escape => allow_upload_callback_api
:escape => allow_upload_callback_api,
:async_options => async_callback_api_commands
**参数**
@@ -157,6 +158,9 @@ title: Ruby SDK 使用指南 | 七牛云存储
`foo=bar&w=$(imageInfo.width)&h=$(imageInfo.height)&exif=$(exif)`
:async_options
: 可选,字符串类型(String),用于设置文件上传成功后,执行指定的预转指令。参见 [uploadToken 之 asyncOps 说明](http://docs.qiniutek.com/v3/api/io/#uploadToken-asyncOps)
**返回值**
返回一个字符串类型(String)的用于上传文件用的临时授权 `upload_token`
+1
View File
@@ -252,6 +252,7 @@ module Qiniu
#token_obj.callback_body_type = opts[:callback_body_type]
#token_obj.customer = opts[:customer]
#token_obj.escape = opts[:escape]
#token_obj.async_options = opts[:async_options]
token_obj.generate_token
end
+1 -1
View File
@@ -5,7 +5,7 @@ module Qiniu
module Version
MAJOR = 3
MINOR = 4
PATCH = 0
PATCH = 1
# Returns a version string by joining <tt>MAJOR</tt>, <tt>MINOR</tt>, and <tt>PATCH</tt> with <tt>'.'</tt>
#
# Example
+3 -1
View File
@@ -10,7 +10,7 @@ module Qiniu
include Utils
attr_accessor :scope, :expires_in, :callback_url, :callback_body_type, :customer, :escape
attr_accessor :scope, :expires_in, :callback_url, :callback_body_type, :customer, :escape, :async_options
def initialize(opts = {})
@scope = opts[:scope]
@@ -19,6 +19,7 @@ module Qiniu
@callback_body_type = opts[:callback_body_type]
@customer = opts[:customer]
@escape = opts[:escape]
@async_options = opts[:async_options]
end
def generate_signature
@@ -27,6 +28,7 @@ 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?
Utils.urlsafe_base64_encode(params.to_json)
end
+6 -1
View File
@@ -20,7 +20,12 @@ module Qiniu
local_file = File.expand_path('../' + @key, __FILE__)
upopts = {:scope => @bucket, :expires_in => 3600, :customer => "why404@gmail.com"}
upopts = {
:scope => @bucket,
:expires_in => 3600,
:customer => "why404@gmail.com",
:async_options => "imageView/1/w/120/h/120"
}
uptoken = Qiniu::RS.generate_upload_token(upopts)
data = Qiniu::RS.upload_file :uptoken => uptoken, :file => local_file, :bucket => @bucket, :key => @key
puts data.inspect