mirror of
https://github.com/wahyd4/ruby-sdk.git
synced 2026-08-09 04:46:10 +10:00
end user module
This commit is contained in:
@@ -11,6 +11,7 @@ module Qiniu
|
||||
autoload :Auth, 'qiniu/rs/auth'
|
||||
autoload :IO, 'qiniu/rs/io'
|
||||
autoload :RS, 'qiniu/rs/rs'
|
||||
autoload :EU, 'qiniu/rs/eu'
|
||||
autoload :Pub, 'qiniu/rs/pub'
|
||||
autoload :Image, 'qiniu/rs/image'
|
||||
autoload :AccessToken, 'qiniu/tokens/access_token'
|
||||
@@ -60,6 +61,16 @@ module Qiniu
|
||||
code == StatusOK
|
||||
end
|
||||
|
||||
def set_watermark(customer_id, options = {})
|
||||
code, data = EU.set_watermark(customer_id, options)
|
||||
code == StatusOK
|
||||
end
|
||||
|
||||
def get_watermark(customer_id)
|
||||
code, data = EU.get_watermark(customer_id)
|
||||
code == StatusOK ? data : false
|
||||
end
|
||||
|
||||
def put_auth(expires_in = nil, callback_url = nil)
|
||||
code, data = IO.put_auth(expires_in, callback_url)
|
||||
code == StatusOK ? data["url"] : false
|
||||
|
||||
@@ -24,6 +24,7 @@ module Qiniu
|
||||
:io_host => "http://iovip.qbox.me",
|
||||
:up_host => "http://m1.qbox.me:13019",
|
||||
:pub_host => "http://m1.qbox.me:13012",
|
||||
:eu_host => "http://m1.qbox.me:15000",
|
||||
:client_id => "a75604760c4da4caaa456c0c5895c061c3065c5a",
|
||||
:client_secret => "75df554a39f58accb7eb293b550fa59618674b7d",
|
||||
:access_key => "",
|
||||
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
module Qiniu
|
||||
module RS
|
||||
module EU
|
||||
class << self
|
||||
include Utils
|
||||
|
||||
def set_watermark(customer_id, options = {})
|
||||
Auth.request Config.settings[:pub_host] + '/set', options.merge({:customer => customer_id})
|
||||
end
|
||||
|
||||
def get_watermark(customer_id)
|
||||
Auth.request Config.settings[:pub_host] + '/get', {:customer => customer_id}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
require 'spec_helper'
|
||||
require 'qiniu/rs/eu'
|
||||
|
||||
module Qiniu
|
||||
module RS
|
||||
describe EU do
|
||||
|
||||
before :all do
|
||||
@customer_id = "awhy.xu@gmail.com"
|
||||
end
|
||||
|
||||
context ".set_watermark" do
|
||||
it "should works" do
|
||||
options = {
|
||||
:text => "Powered by QiniuRS"
|
||||
}
|
||||
code, data = Qiniu::RS::EU.set_watermark(@customer_id, options)
|
||||
code.should == 200
|
||||
puts data.inspect
|
||||
end
|
||||
end
|
||||
|
||||
context ".get_watermark" do
|
||||
it "should works" do
|
||||
code, data = Qiniu::RS::EU.get_watermark(@customer_id)
|
||||
code.should == 200
|
||||
puts data.inspect
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -67,6 +67,25 @@ module Qiniu
|
||||
end
|
||||
end
|
||||
|
||||
context ".set_watermark" do
|
||||
it "should works" do
|
||||
options = {
|
||||
:text => "Powered by QiniuRS"
|
||||
}
|
||||
result = Qiniu::RS.set_watermark(1, options)
|
||||
result.should_not be_false
|
||||
puts result.inspect
|
||||
end
|
||||
end
|
||||
|
||||
context ".get_watermark" do
|
||||
it "should works" do
|
||||
result = Qiniu::RS.get_watermark(1)
|
||||
result.should_not be_false
|
||||
puts result.inspect
|
||||
end
|
||||
end
|
||||
|
||||
context ".put_auth" do
|
||||
it "should works" do
|
||||
result = Qiniu::RS.put_auth(10)
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@ RSpec.configure do |config|
|
||||
:rs_host => "http://m1.qbox.me:13003",
|
||||
:io_host => "http://m1.qbox.me:13004",
|
||||
:up_host => "http://m1.qbox.me:13019",
|
||||
:pub_host => "http://m1.qbox.me:13012"
|
||||
:pub_host => "http://m1.qbox.me:13012",
|
||||
:eu_host => "http://m1.qbox.me:15000",
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user