Module: Qiniu::Fop::Persistance
- Defined in:
- lib/qiniu/pfop.rb
Defined Under Namespace
Classes: PfopPolicy
Constant Summary collapse
- API_HOST =
'http://api.qiniu.com'
- PFOP_URL =
API_HOST + '/pfop/'
- PREFOP_URL =
pfop
API_HOST + '/status/get/prefop?id='
Class Method Summary collapse
Class Method Details
.generate_p1_url(url, fop) ⇒ Object
prefop
111 112 113 114 115 116 117 118 |
# File 'lib/qiniu/pfop.rb', line 111 def generate_p1_url (url, fop) # 如果fop是ApiSpecification,则各字段按固定顺序组织,保证一致性 # 否则由调用者保证固定字段顺序 fop = CGI.escape(fop.to_s).gsub('+', '%20') ### 生成url return url + '?p/1/' + fop end |
.pfop(args) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/qiniu/pfop.rb', line 79 def pfop (args) ### 生成fop指令串 if args.is_a?(PfopPolicy) then # PfopPolicy的各个字段按固定顺序组织 body = args.to_query_string() elsif args.is_a?(Hash) then # 无法保证固定字段顺序 body = HTTP.generate_query_string(args) else # 由调用者保证固定字段顺序 body = args.to_s end ### 发送请求 return HTTP.management_post(PFOP_URL, body) end |
.prefop(persistent_id) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/qiniu/pfop.rb', line 98 def prefop (persistent_id) ### 抽取persistentId if persistent_id.is_a?(Hash) then pid = persistent_id['persistentId'] else pid = persistent_id.to_s end ### 发送请求 url = PREFOP_URL + pid return HTTP.api_get(url) end |