为 upload 的最新版本接口添加 content-type/mimeType 设置方法。

This commit is contained in:
Liang Tao
2014-11-28 16:22:58 +08:00
parent 804fa4d5b6
commit b8f43a1ded
3 changed files with 16 additions and 7 deletions
+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)
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 = 2
MINOR = 4
PATCH = 0
# Returns a version string by joining <tt>MAJOR</tt>, <tt>MINOR</tt>, and <tt>PATCH</tt> with <tt>'.'</tt>
#
# Example