diff --git a/Gemfile.lock b/Gemfile.lock
index e0df932..c162822 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -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)
diff --git a/lib/qiniu/upload.rb b/lib/qiniu/upload.rb
old mode 100755
new mode 100644
index 4e76eec..c103e1a
--- a/lib/qiniu/upload.rb
+++ b/lib/qiniu/upload.rb
@@ -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
diff --git a/lib/qiniu/version.rb b/lib/qiniu/version.rb
index 3fd72d0..2aa467c 100755
--- a/lib/qiniu/version.rb
+++ b/lib/qiniu/version.rb
@@ -3,8 +3,8 @@
module Qiniu
module Version
MAJOR = 6
- MINOR = 3
- PATCH = 2
+ MINOR = 4
+ PATCH = 0
# Returns a version string by joining MAJOR, MINOR, and PATCH with '.'
#
# Example