add Qiniu.fetch method

This commit is contained in:
Forrest Ye
2015-01-05 15:35:43 +08:00
parent 5332645665
commit f1ed9a9783
3 changed files with 11 additions and 0 deletions
+5
View File
@@ -118,6 +118,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
+1
View File
@@ -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",
+5
View File
@@ -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|