mirror of
https://github.com/wahyd4/ruby-sdk.git
synced 2026-08-10 13:26:44 +10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
957b537da0 | ||
|
|
4db869a53a | ||
|
|
a07b323d9d | ||
|
|
f1ed9a9783 |
@@ -16,3 +16,4 @@ spec/reports
|
||||
test/tmp
|
||||
test/version_tmp
|
||||
tmp
|
||||
.idea
|
||||
|
||||
+7
-4
@@ -3,7 +3,7 @@ PATH
|
||||
specs:
|
||||
qiniu (6.5.1)
|
||||
json (~> 1.8)
|
||||
mime-types (~> 1.19)
|
||||
mime-types (~> 2.4.3)
|
||||
rest-client (~> 1.7.3)
|
||||
ruby-hmac (~> 0.4)
|
||||
|
||||
@@ -12,9 +12,9 @@ GEM
|
||||
specs:
|
||||
diff-lcs (1.2.5)
|
||||
fakeweb (1.3.0)
|
||||
json (1.8.2)
|
||||
mime-types (1.25.1)
|
||||
netrc (0.10.3)
|
||||
json (1.8.3)
|
||||
mime-types (2.4.3)
|
||||
netrc (0.11.0)
|
||||
rake (10.4.2)
|
||||
rest-client (1.7.3)
|
||||
mime-types (>= 1.16, < 3.0)
|
||||
@@ -42,3 +42,6 @@ DEPENDENCIES
|
||||
qiniu!
|
||||
rake (>= 0.9)
|
||||
rspec (>= 2.11)
|
||||
|
||||
BUNDLED WITH
|
||||
1.11.2
|
||||
|
||||
@@ -117,6 +117,11 @@ module Qiniu
|
||||
code == StatusOK
|
||||
end
|
||||
|
||||
def fetch(bucket, target_url, key)
|
||||
code, data = Storage.fetch(bucket, target_url, key)
|
||||
code == StatusOK
|
||||
end
|
||||
|
||||
def batch(command, bucket, keys)
|
||||
code, data = Storage.batch(command, bucket, keys)
|
||||
code == StatusOK ? data : false
|
||||
|
||||
@@ -20,6 +20,7 @@ module Qiniu
|
||||
:content_type => 'application/x-www-form-urlencoded',
|
||||
:auth_url => "https://acc.qbox.me/oauth2/token",
|
||||
:rs_host => "http://rs.qiniu.com",
|
||||
:fetch_host => "http://iovip.qbox.me",
|
||||
:rsf_host => "http://rsf.qbox.me",
|
||||
:up_host => "http://up.qiniu.com",
|
||||
:pub_host => "http://pu.qbox.me:10200",
|
||||
|
||||
@@ -82,6 +82,11 @@ module Qiniu
|
||||
return HTTP.management_post(url)
|
||||
end # delete
|
||||
|
||||
def fetch(bucket, target_url, key)
|
||||
url = Config.settings[:fetch_host] + '/fetch/' + Utils.urlsafe_base64_encode(target_url) + '/to/' + encode_entry_uri(bucket, key)
|
||||
return HTTP.management_post(url)
|
||||
end # fetch
|
||||
|
||||
def batch(command, bucket, keys)
|
||||
execs = []
|
||||
keys.each do |key|
|
||||
|
||||
+13
-4
@@ -49,13 +49,22 @@ module Qiniu
|
||||
key = nil,
|
||||
x_vars = nil,
|
||||
opts = {})
|
||||
|
||||
file = File.new(local_file, 'rb')
|
||||
return upload_with_token_2_file_stream(uptoken, file, key, x_vars, opts)
|
||||
end # upload_with_token_2
|
||||
|
||||
def upload_with_token_2_file_stream(uptoken,
|
||||
file,
|
||||
key = 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]
|
||||
@@ -63,8 +72,8 @@ module Qiniu
|
||||
end
|
||||
|
||||
post_data = {
|
||||
:file => file,
|
||||
:multipart => true,
|
||||
:file => file,
|
||||
:multipart => true,
|
||||
}
|
||||
if not uptoken.nil?
|
||||
post_data[:token] = uptoken
|
||||
@@ -78,7 +87,7 @@ module Qiniu
|
||||
|
||||
### 发送请求
|
||||
HTTP.api_post(url, post_data)
|
||||
end # upload_with_token_2
|
||||
end
|
||||
|
||||
### 授权举例
|
||||
# put_policy.bucket | put_policy.key | key | 语义 | 授权
|
||||
|
||||
Reference in New Issue
Block a user