mirror of
https://github.com/wahyd4/ruby-sdk.git
synced 2026-08-09 12:56:21 +10:00
为 upload 的最新版本接口添加 content-type/mimeType 设置方法。
This commit is contained in:
+1
-1
@@ -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
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user